Compute Graph Framework SDK Reference  5.8
ComputeGraph.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) 2019-2021 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_COMPUTEGRAPH_HPP_
32#define DW_FRAMEWORK_COMPUTEGRAPH_HPP_
33
34#include <dw/core/base/Types.h>
35
36#include <dwcgf/Types.hpp>
38#include <dwcgf/node/Node.hpp>
39#include <dwcgf/pass/Pass.hpp>
40
43#include <dw/core/container/Span.hpp>
44#include <dw/core/container/VectorFixed.hpp>
45
46using dw::core::span;
47
48namespace dw
49{
50namespace framework
51{
53{
54public:
55 explicit ComputeGraph();
56
57 virtual ~ComputeGraph() = default;
58
59 /***
60 * @brief Set the channel array for this graph. These are
61 * the channels this graph will use for inputs, outputs,
62 * and connections between nodes.
63 * @param[in] channels A contiguous array holding the all the channel pointers for the graph.
64 * @return DW_SUCCESS - All channels are accepted as input.
65 * DW_INVALID_ARGUMENT - @ref channels is not a valid pointer.
66 * DW_INVALID_ARGUMENT - size of @ref channels is 0.
67 * DW_FAILURE - The channels cannot be set.
68 */
69 dwStatus setChannels(span<ChannelObject*> channels);
70
71 /***
72 * @brief Set the node array for this graph. These are
73 * the nodes this graph will use as its vertices, while
74 * channels are the edges.
75 * @param[in] nodes A contiguous array holding the all the node pointers for the graph.
76 * @return DW_SUCCESS - All nodes are accepted as input.
77 * DW_INVALID_ARGUMENT - @ref nodes is not a valid pointer.
78 * DW_INVALID_ARGUMENT - size of @ref nodes is 0.
79 * DW_FAILURE - The nodes cannot be set.
80 */
81 dwStatus setNodes(span<Node*> nodes);
82
83 /***
84 * @brief Set the connection array for this graph.
85 * @param[in] nodes A contiguous array holding the all the connections for the graph.
86 * @return DW_SUCCESS - All nodes are accepted as input.
87 * DW_INVALID_ARGUMENT - @ref connections is not a valid pointer.
88 * DW_INVALID_ARGUMENT - size of @ref connections is 0.
89 * DW_FAILURE - The nodes cannot be set.
90 */
91 dwStatus setConnections(span<const Connection> connections);
92
93 /***
94 * @brief Resets all the connections between nodes.
95 * @return DW_SUCCESS - The connections are reset.
96 * DW_CALL_NOT_ALLOWED - @ref setNodes(span<Node*>) has not been called with valid data.
97 * DW_CALL_NOT_ALLOWED - @ref setChannels(span<ChannelObject*>) has not been called with valid data.
98 */
99 dwStatus resetConnections();
100
101 /***
102 * @brief Build and validate the graph.
103 * @return DW_SUCCESS - The graph is ready for execution.
104 * DW_CALL_NOT_ALLOWED - @ref setNodes(span<Node*>) has not been called with valid data.
105 * DW_CALL_NOT_ALLOWED - @ref setChannels(span<ChannelObject*>) has not been called with valid data.
106 * DW_CALL_NOT_ALLOWED - @ref setConnections(span<const Connection>) has not been called with valid data.
107 * DW_INTERNAL_ERROR - Channels from @ref setChannels(span<ChannelObject*>) do not connect to one
108 * input and one output exactly.
109 * DW_INTERNAL_ERROR - There is at least one cycle detected in the graph.
110 * DW_INTERNAL_ERROR - Not all nodes are used.
111 * DW_INTERNAL_ERROR - All node inputs do not have input channels.
112 * DW_INTERNAL_ERROR - All node outputs do not have output channels.
113 */
114 dwStatus build();
115
116 /***
117 * @brief Get a pass by name.
118 * @param[out] pass The pass to populate.
119 * @param[in] key String key is node_name.pass# (i.e., "detector.0").
120 * @return DW_SUCCESS - The pass is populated.
121 * DW_CALL_NOT_ALLOWED - @ref build has not been called.
122 * DW_INVALID_ARGUMENT - @ref key is not valid.
123 */
124 dwStatus getPass(Pass*& pass, const char* key);
125
126 /***
127 * @brief Get the pass list for a specific node.
128 * @param[out] passList The list to populate with passes.
129 * @param[in] nodeIndex The index of the node.
130 * @return DW_SUCCESS - The pass list is populated.
131 * DW_CALL_NOT_ALLOWED - @ref build has not been called.
132 * DW_INVALID_ARGUMENT - @ref nodeIndex is not valid.
133 */
134 dwStatus getPasses(VectorFixed<Pass*>& passList, uint64_t nodeIndex);
135
136 /***
137 * @brief Get the pass list for all nodes in a specific order.
138 * @param[out] passList The list to populate with passes.
139 * @param[in] order The traversal order of a the graph.
140 * @return DW_SUCCESS - The pass list is populated.
141 * DW_CALL_NOT_ALLOWED - @ref build has not been called.
142 * DW_INVALID_ARGUMENT - @ref order is not valid.
143 */
144 dwStatus getPasses(VectorFixed<Pass*>& passList, ComputeGraphTraversalOrder order);
145
146 /***
147 * @brief Get the pass list for all nodes filtered by a specific processor type and process type in a specific order.
148 * @param[out] passList The list to populate with passes.
149 * @param[in] processorType The processor type.
150 * @param[in] processType The process type.
151 * @param[in] order The traversal order of a the graph.
152 * @return DW_SUCCESS - The pass list is populated.
153 * DW_CALL_NOT_ALLOWED - @ref build has not been called.
154 * DW_INVALID_ARGUMENT - @ref order is not valid.
155 */
156 dwStatus getPasses(VectorFixed<Pass*>& passList, dwProcessorType processorType, dwProcessType processType, ComputeGraphTraversalOrder order);
157
158 /***
159 * @brief Execute the compute graph.
160 * @param[in] order The traversal order of the graph to run.
161 * @return DW_SUCCESS - The graph is executed.
162 * DW_CALL_NOT_ALLOWED - @ref build has not been called.
163 * DW_INVALID_ARGUMENT - @ref type is not a valid @ref ComputeGraphTraversalOrder
164 * DW_FAILURE
165 */
167
168 /***
169 * @brief Prints the adjacency matrix.
170 * @return DW_SUCCESS - The matrix is output.
171 * DW_CALL_NOT_ALLOWED - @ref setNodes(span<Node*>) has not been called with valid data.
172 * DW_CALL_NOT_ALLOWED - @ref setChannels(span<ChannelObject*>) has not been called with valid data.
173 * DW_CALL_NOT_ALLOWED - @ref setConnections(span<const Connection>) has not been called with valid data.
174 */
176
177protected:
178 std::unique_ptr<ComputeGraphImpl> m_impl;
179};
180}
181}
182#endif // DW_FRAMEWORK_COMPUTEGRAPH_HPP_
dwStatus setConnections(span< const Connection > connections)
dwStatus getPasses(VectorFixed< Pass * > &passList, ComputeGraphTraversalOrder order)
dwStatus run(ComputeGraphTraversalOrder order)
dwStatus getPass(Pass *&pass, const char *key)
dwStatus getPasses(VectorFixed< Pass * > &passList, uint64_t nodeIndex)
dwStatus setNodes(span< Node * > nodes)
virtual ~ComputeGraph()=default
dwStatus getPasses(VectorFixed< Pass * > &passList, dwProcessorType processorType, dwProcessType processType, ComputeGraphTraversalOrder order)
dwStatus setChannels(span< ChannelObject * > channels)
std::unique_ptr< ComputeGraphImpl > m_impl
Pass is a runnable describes the metadata of a pass.
Definition: Pass.hpp:49
Definition: Exception.hpp:47