Compute Graph Framework SDK Reference  5.8
PassCollectionDescriptor.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_PASSCOLLECTIONDESCRIPTOR_HPP_
32#define DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
33
35
36#include <dw/core/container/VectorFixed.hpp>
37
38namespace dw
39{
40namespace framework
41{
42
45{
46public:
48 PassDescriptor(dw::core::StringView const& name, dwProcessorType const processorType, const bool hasExplicitDependencies, size_t const dependencies);
49
51 dw::core::StringView const& getName() const noexcept;
52
54 dwProcessorType getProcessorType() const noexcept;
55
57 bool hasExplicitDependencies() const noexcept;
58
61
63 dw::core::StringView const& getDependency(size_t const index) const;
64
66 void addDependency(dw::core::StringView const& dependency);
67
68private:
70 dw::core::StringView m_name;
72 dwProcessorType m_processorType;
74 bool m_hasExplicitDependencies;
76 dw::core::VectorFixed<dw::core::StringView> m_dependencies;
77};
78
81{
82public:
84 explicit PassCollectionDescriptor(size_t const capacity);
85
87 size_t getSize() const;
88
90 const PassDescriptor& getDescriptor(size_t const index) const;
91
97 size_t getIndex(dw::core::StringView const& identifier) const;
98
104 const PassDescriptor& getDescriptor(dw::core::StringView const& identifier) const;
105
107 bool isValid(size_t const index) const noexcept;
108
110 bool isValid(dw::core::StringView const& identifier) const noexcept;
111
117 void addDescriptor(const PassDescriptor& descriptor);
118
119private:
121 dw::core::VectorFixed<PassDescriptor> m_descriptors;
122};
123
124namespace detail
125{
126
128template <
129 typename NodeT, size_t Index,
130 typename std::enable_if_t<Index == passSize<NodeT>(), void>* = nullptr>
131void addPassDescriptor(PassCollectionDescriptor& collection)
132{
133 (void)collection;
134}
135
137template <
138 typename NodeT, size_t Index,
139 typename std::enable_if_t<Index<passSize<NodeT>(), void>* = nullptr>
140 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
141 // coverity[autosar_cpp14_a2_10_5_violation]
142 void addPassDescriptor(PassCollectionDescriptor& collection)
143{
144 constexpr auto dependencies = passDependencies<NodeT, Index>();
145 PassDescriptor descriptor(passName<NodeT, Index>(), passProcessorType<NodeT, Index>(), hasPassDependencies<NodeT, Index>(), dependencies.size());
146 for (size_t i = 0; i < dependencies.size(); ++i)
147 {
148 descriptor.addDependency(dependencies[i]);
149 }
150 collection.addDescriptor(descriptor);
151
152 addPassDescriptor<NodeT, Index + 1>(collection);
153}
154
155} // namespace detail
156
158template <typename NodeT>
160{
161 PassCollectionDescriptor collection(passSize<NodeT>());
162 detail::addPassDescriptor<NodeT, 0>(collection);
163 return collection;
164}
165
166} // namespace framework
167} // namespace dw
168
169#endif // DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
const PassDescriptor & getDescriptor(dw::core::StringView const &identifier) const
bool isValid(size_t const index) const noexcept
Check if the passed index is valid, which mean is within [0, size()).
PassCollectionDescriptor(size_t const capacity)
Constructor.
const PassDescriptor & getDescriptor(size_t const index) const
Get the pass descriptor for the passed index.
size_t getIndex(dw::core::StringView const &identifier) const
bool isValid(dw::core::StringView const &identifier) const noexcept
Check if the passed pass name matches a pass descriptor in the collection.
void addDescriptor(const PassDescriptor &descriptor)
size_t getSize() const
Get the number of pass descriptors.
size_t getNumberOfDependencies() const
Get number of dependencies.
dwProcessorType getProcessorType() const noexcept
Get the processor type running on.
dw::core::StringView const & getName() const noexcept
Get the pass name.
bool hasExplicitDependencies() const noexcept
Check if the pass specifies explicit dependencies.
dw::core::StringView const & getDependency(size_t const index) const
Get the dependent on pass name by index.
PassDescriptor(dw::core::StringView const &name, dwProcessorType const processorType, const bool hasExplicitDependencies, size_t const dependencies)
Constructor.
void addDependency(dw::core::StringView const &dependency)
Add another pass name as a dependency.
static PassCollectionDescriptor createPassCollectionDescriptor()
Create a pass collection descriptor for a give node.
Definition: Exception.hpp:47