2 * Copyright (c) 2017 ARM Limited.
4 * SPDX-License-Identifier: MIT
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #ifndef __ARM_COMPUTE_GRAPH_GRAPH_H__
25 #define __ARM_COMPUTE_GRAPH_GRAPH_H__
27 #include "arm_compute/graph/INode.h"
28 #include "arm_compute/graph/Tensor.h"
29 #include "arm_compute/graph/Types.h"
30 #include "support/ToolchainSupport.h"
48 /** Prevent instances from being copy constructed */
49 Graph(const Graph &) = delete;
50 /** Prevent instances from being copy assigned */
51 const Graph &operator=(const Graph &) = delete;
52 /** Prevent instances from being move constructed */
53 Graph(Graph &&) = delete;
54 /** Prevent instances from being move assigned */
55 Graph &operator=(Graph &&) = delete;
56 /** Executes the graph */
58 /** Adds a node to the graph
60 * @param[in] node Node to add
62 void add_node(std::unique_ptr<INode> node);
63 /** Adds a tensor to the graph
65 * @param[in] tensor Tensor to add
67 void add_tensor(std::unique_ptr<Tensor> tensor);
68 /** Sets an execution hint to the graph
70 * @note Hint is propagated to the following node and as per name
71 * its just a hint/preference to be considered by the graph executor
73 * @param[in] hint execution hint
75 void set_hint(Hint hint);
76 /** Manually sets the output of the current node
78 * @param[in] tmp Output info to set
80 void set_temp(TensorInfo &&tmp);
82 /** Sets whether to enable information print out
84 * @param[in] is_enabled Set to true if need info printed out
86 void set_info_enablement(bool is_enabled);
90 std::unique_ptr<Private> _pimpl; /**< Internal implementation class */
93 /** Overloaded stream operator to add a tensor through its tensor info to the graph
95 * @param[in, out] graph Graph to add the tensor
96 * @param[in] info Tensor information of the tensor to be added
98 * @return Updated graph
100 Graph &operator<<(Graph &graph, TensorInfo &&info);
101 /** Overloaded stream operator to add a tensor to the graph
103 * @param[in, out] graph Graph to add the tensor
104 * @param[in] tensor Tensor to be added
106 * @return Updated graph
108 Graph &operator<<(Graph &graph, Tensor &&tensor);
109 /** Overloaded stream operator to provide an execution hint to the graph
111 * @param[in, out] graph Graph to provide the hint to
112 * @param[in] hint Execution hint to be considered
114 * @return Updated graph
116 Graph &operator<<(Graph &graph, Hint hint);
117 /** Overloaded stream operator to add a node to the graph
119 * @param[in, out] graph Graph to add the tensor
120 * @param[in] node Node to be added
122 * @return Updated graph
124 template <typename Node>
125 Graph &operator<<(Graph &graph, Node node)
127 graph.add_node(arm_compute::support::cpp14::make_unique<Node>(std::move(node)));
131 } // namespace arm_compute
132 #endif /* __ARM_COMPUTE_GRAPH_GRAPH_H__ */