• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.6
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
    PassDescriptor.hpp
    Go to the documentation of this file.
    1
    2//
    3// Notice
    4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
    5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
    7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
    8//
    9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
    10// information or for any infringement of patents or other rights of third parties that may
    11// result from its use. No license is granted by implication or otherwise under any patent
    12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
    13// expressly authorized by NVIDIA. Details are subject to change without notice.
    14// This code supersedes and replaces all information previously supplied.
    15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
    16// components in life support devices or systems without express written approval of
    17// NVIDIA CORPORATION & AFFILIATES.
    18//
    19// SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
    20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
    21//
    22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
    23// property and proprietary rights in and to this material, related
    24// documentation and any modifications thereto. Any use, reproduction,
    25// disclosure or distribution of this material and related documentation
    26// without an express license agreement from NVIDIA CORPORATION or
    27// its affiliates is strictly prohibited.
    28//
    30
    31#ifndef DW_FRAMEWORK_PASSDESCRIPTOR_HPP_
    32#define DW_FRAMEWORK_PASSDESCRIPTOR_HPP_
    33
    34#include <dw/core/base/Types.h>
    35#include <dw/core/container/StringView.hpp>
    36
    37#include <array>
    38#include <cstddef>
    39#include <tuple>
    40#include <type_traits>
    41#include <utility>
    42
    43namespace dw
    44{
    45namespace framework
    46{
    47
    54template <typename... Args>
    55constexpr auto describePassCollection(const Args&&... args)
    56{
    57 return std::make_tuple(std::forward<const Args>(args)...);
    58}
    59
    60// coverity[autosar_cpp14_a0_1_1_violation]
    61// coverity[autosar_cpp14_m0_1_4_violation]
    62static constexpr size_t PASS_NAME{0U};
    63// coverity[autosar_cpp14_a0_1_1_violation]
    64// coverity[autosar_cpp14_m0_1_4_violation]
    65static constexpr size_t PASS_PROCESSOR_TYPE{1U};
    66// coverity[autosar_cpp14_a0_1_1_violation]
    67// coverity[autosar_cpp14_m0_1_4_violation]
    68static constexpr size_t PASS_DEPENDENCIES{2U};
    69
    75constexpr std::tuple<dw::core::StringView, dwProcessorType> describePass(
    76 dw::core::StringView const&& name, dwProcessorType processorType)
    77{
    78 return std::make_tuple(
    79 // TODO(dwplc): FP -- must use std::move for && parameter
    80 // coverity[autosar_cpp14_a18_9_3_violation]
    81 std::move(name),
    82 std::move(processorType));
    83}
    84
    91// Overloaded functions are provided for ease of use
    92// coverity[autosar_cpp14_a2_10_5_violation]
    93template <typename DependenciesT>
    94constexpr auto describePass(
    95 dw::core::StringView const&& name, dwProcessorType processorType, DependenciesT dependencies) -> std::tuple<dw::core::StringView, dwProcessorType, DependenciesT>
    96{
    97 return std::make_tuple(
    98 std::move(name),
    99 std::move(processorType),
    100 std::move(dependencies));
    101}
    102
    108template <typename... Args>
    109constexpr auto describePassDependencies(const Args&&... args) -> std::array<dw::core::StringView, sizeof...(Args)>
    110{
    111 return {std::forward<const Args>(args)...};
    112}
    113
    115template <typename Node>
    116constexpr auto describePasses()
    117{
    118 return Node::describePasses();
    119}
    120
    122template <typename Node>
    123constexpr std::size_t passSize()
    124{
    125 return std::tuple_size<decltype(describePasses<Node>())>::value;
    126}
    127
    129// Overloaded functions provide the same functionality for different argument types
    130// coverity[autosar_cpp14_a2_10_5_violation]
    131template <typename Node>
    132constexpr bool isValidPass(std::size_t passID)
    133{
    134 return passID < passSize<Node>();
    135}
    136
    137namespace detail
    138{
    139
    141template <
    142 typename Node, size_t Index,
    143 typename std::enable_if_t<Index == passSize<Node>(), void>* = nullptr>
    144constexpr std::size_t passIndex(dw::core::StringView identifier)
    145{
    146 (void)identifier;
    147 return 0;
    148}
    149
    151template <
    152 typename Node, size_t Index,
    153 typename std::enable_if_t<Index<passSize<Node>(), void>* = nullptr>
    154 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    155 // coverity[autosar_cpp14_a2_10_5_violation]
    156 constexpr std::size_t passIndex(dw::core::StringView identifier)
    157{
    158 constexpr auto name = std::get<dw::framework::PASS_NAME>(std::get<Index>(describePasses<Node>()));
    159 if (name == identifier)
    160 {
    161 return 0;
    162 }
    163 return 1 + passIndex<Node, Index + 1>(identifier);
    164}
    165
    166} // namespace detail
    167
    169// TODO(dwplc): FP -- The other passIndex() functions are defined in a namespace
    170// coverity[autosar_cpp14_a2_10_5_violation]
    171template <typename Node>
    172constexpr size_t passIndex(dw::core::StringView identifier)
    173{
    174 return detail::passIndex<Node, 0>(identifier);
    175}
    176
    178template <typename Node>
    179constexpr bool isValidPass(dw::core::StringView identifier)
    180{
    181 constexpr size_t index = passIndex<Node>(identifier);
    182 return isValidPass<Node>(index);
    183}
    184
    186template <typename Node, size_t Index>
    187constexpr dw::core::StringView passName()
    188{
    189 return std::get<dw::framework::PASS_NAME>(std::get<Index>(describePasses<Node>()));
    190}
    191
    193template <typename Node, size_t Index>
    194constexpr dwProcessorType passProcessorType()
    195{
    196 return std::get<dw::framework::PASS_PROCESSOR_TYPE>(std::get<Index>(describePasses<Node>()));
    197}
    198
    200template <typename Node, size_t Index>
    201constexpr bool hasPassDependencies()
    202{
    203 constexpr auto pass = std::get<Index>(describePasses<Node>());
    204 return std::tuple_size<decltype(pass)>() > PASS_DEPENDENCIES;
    205}
    206
    208template <
    209 typename Node, size_t Index,
    210 typename std::enable_if_t<hasPassDependencies<Node, Index>(), void>* = nullptr>
    211constexpr auto passDependencies()
    212{
    213 return std::get<PASS_DEPENDENCIES>(std::get<Index>(describePasses<Node>()));
    214}
    215
    217template <
    218 typename Node, size_t Index,
    219 typename std::enable_if_t<!hasPassDependencies<Node, Index>(), void>* = nullptr>
    220// Overloaded functions provide the same functionality for different argument types
    221// coverity[autosar_cpp14_a2_10_5_violation]
    222constexpr auto passDependencies()
    223{
    224 return std::array<dw::core::StringView, 0>();
    225}
    226
    227} // namespace framework
    228} // namespace dw
    229
    230#endif // DW_FRAMEWORK_PASSDESCRIPTOR_HPP_
    constexpr std::size_t passSize()
    Get the number of passes of the passed node.
    constexpr dwProcessorType passProcessorType()
    Get the processor type of a pass.
    static constexpr size_t PASS_NAME
    constexpr bool isValidPass(std::size_t passID)
    Check if pass index is valid.
    constexpr auto passDependencies()
    Get the dependencies of a pass.
    constexpr dw::core::StringView passName()
    Get the name of a pass.
    constexpr size_t passIndex(dw::core::StringView identifier)
    Get the the pass index for a pass identified by name.
    constexpr std::tuple< dw::core::StringView, dwProcessorType > describePass(dw::core::StringView const &&name, dwProcessorType processorType)
    constexpr auto describePasses()
    Get described passes for the passed node.
    constexpr bool hasPassDependencies()
    Check if a pass specifies explicit dependencies.
    static constexpr size_t PASS_PROCESSOR_TYPE
    constexpr auto describePassCollection(const Args &&... args)
    constexpr auto describePassDependencies(const Args &&... args) -> std::array< dw::core::StringView, sizeof...(Args)>
    static constexpr size_t PASS_DEPENDENCIES
    Definition: Exception.hpp:47
    人人超碰97caoporen国产