• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.8
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 std::move(name),
    80 std::move(processorType));
    81}
    82
    89// Overloaded functions are provided for ease of use
    90// coverity[autosar_cpp14_a2_10_5_violation]
    91template <typename DependenciesT>
    92constexpr auto describePass(
    93 dw::core::StringView const&& name, dwProcessorType processorType, DependenciesT dependencies) -> std::tuple<dw::core::StringView, dwProcessorType, DependenciesT>
    94{
    95 return std::make_tuple(
    96 std::move(name),
    97 std::move(processorType),
    98 std::move(dependencies));
    99}
    100
    106template <typename... Args>
    107constexpr auto describePassDependencies(const Args&&... args) -> std::array<dw::core::StringView, sizeof...(Args)>
    108{
    109 return {std::forward<const Args>(args)...};
    110}
    111
    113template <typename Node>
    114constexpr auto describePasses()
    115{
    116 return Node::describePasses();
    117}
    118
    120template <typename Node>
    121constexpr std::size_t passSize()
    122{
    123 return std::tuple_size<decltype(describePasses<Node>())>::value;
    124}
    125
    127// Overloaded functions provide the same functionality for different argument types
    128// coverity[autosar_cpp14_a2_10_5_violation]
    129template <typename Node>
    130constexpr bool isValidPass(std::size_t passID)
    131{
    132 return passID < passSize<Node>();
    133}
    134
    135namespace detail
    136{
    137
    139template <
    140 typename Node, size_t Index,
    141 typename std::enable_if_t<Index == passSize<Node>(), void>* = nullptr>
    142constexpr std::size_t passIndex(dw::core::StringView identifier)
    143{
    144 (void)identifier;
    145 return 0;
    146}
    147
    149template <
    150 typename Node, size_t Index,
    151 typename std::enable_if_t<Index<passSize<Node>(), void>* = nullptr>
    152 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    153 // coverity[autosar_cpp14_a2_10_5_violation]
    154 constexpr std::size_t passIndex(dw::core::StringView identifier)
    155{
    156 constexpr auto name = std::get<dw::framework::PASS_NAME>(std::get<Index>(describePasses<Node>()));
    157 if (name == identifier)
    158 {
    159 return 0;
    160 }
    161 return 1 + passIndex<Node, Index + 1>(identifier);
    162}
    163
    164} // namespace detail
    165
    167// TODO(dwplc): FP -- The other passIndex() functions are defined in a namespace
    168// coverity[autosar_cpp14_a2_10_5_violation]
    169template <typename Node>
    170constexpr size_t passIndex(dw::core::StringView identifier)
    171{
    172 return detail::passIndex<Node, 0>(identifier);
    173}
    174
    176template <typename Node>
    177constexpr bool isValidPass(dw::core::StringView identifier)
    178{
    179 constexpr size_t index = passIndex<Node>(identifier);
    180 return isValidPass<Node>(index);
    181}
    182
    184template <typename Node, size_t Index>
    185constexpr dw::core::StringView passName()
    186{
    187 return std::get<dw::framework::PASS_NAME>(std::get<Index>(describePasses<Node>()));
    188}
    189
    191template <typename Node, size_t Index>
    192constexpr dwProcessorType passProcessorType()
    193{
    194 return std::get<dw::framework::PASS_PROCESSOR_TYPE>(std::get<Index>(describePasses<Node>()));
    195}
    196
    198template <typename Node, size_t Index>
    199constexpr bool hasPassDependencies()
    200{
    201 constexpr auto pass = std::get<Index>(describePasses<Node>());
    202 return std::tuple_size<decltype(pass)>() > PASS_DEPENDENCIES;
    203}
    204
    206template <
    207 typename Node, size_t Index,
    208 typename std::enable_if_t<hasPassDependencies<Node, Index>(), void>* = nullptr>
    209constexpr auto passDependencies()
    210{
    211 return std::get<PASS_DEPENDENCIES>(std::get<Index>(describePasses<Node>()));
    212}
    213
    215template <
    216 typename Node, size_t Index,
    217 typename std::enable_if_t<!hasPassDependencies<Node, Index>(), void>* = nullptr>
    218// Overloaded functions provide the same functionality for different argument types
    219// coverity[autosar_cpp14_a2_10_5_violation]
    220constexpr auto passDependencies()
    221{
    222 return std::array<dw::core::StringView, 0>();
    223}
    224
    225} // namespace framework
    226} // namespace dw
    227
    228#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国产