blob: 0aaed1da7d2fc33d9a3e7e71cc1808bf49b7f234 [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
Giuseppe Rossinibb365de2019-02-15 10:24:47 +00002 * Copyright (c) 2018-2019 ARM Limited.
Georgios Pinitasd8734b52017-12-22 15:27:52 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
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
22 * SOFTWARE.
23 */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010024#ifndef __ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H__
25#define __ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H__
Georgios Pinitasd8734b52017-12-22 15:27:52 +000026
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/graph/ITensorAccessor.h"
Isabella Gottardi0ae5de92019-03-14 10:32:11 +000028#include "arm_compute/graph/LayerDescriptors.h"
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010029#include "arm_compute/graph/Types.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000030
31namespace arm_compute
32{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010033namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000034{
35// Forward declaration
36class Graph;
37
38/** Graph builder class
39 *
40 * Builds and compiles a graph
41 */
42class GraphBuilder final
43{
44public:
45 /** Adds a Const node to the graph
46 *
47 * @param[in] g Graph to add the node to
48 * @param[in] params Common node parameters
49 * @param[in] desc Tensor descriptor of the node
50 * @param[in] accessor (Optional) Accessor of the const node data
51 *
52 * @return Node ID of the created node, EmptyNodeID in case of error
53 */
Michalis Spyrou299fdd32019-05-01 13:03:59 +010054 static NodeID add_const_node(Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000055 /** Adds an input layer node to the graph
56 *
57 * @param[in] g Graph to add the node to
58 * @param[in] params Common node parameters
59 * @param[in] desc Tensor descriptor of the Tensor
60 * @param[in] accessor (Optional) Accessor of the input node data
61 *
62 * @return Node ID of the created node, EmptyNodeID in case of error
63 */
Michalis Spyrou299fdd32019-05-01 13:03:59 +010064 static NodeID add_input_node(Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000065 /** Adds an output layer node to the graph
66 *
67 * @param[in] g Graph to add the node to
68 * @param[in] params Common node parameters
69 * @param[in] input Input to the output node as a NodeID-Index pair
70 * @param[in] accessor (Optional) Accessor of the output node data
71 *
72 * @return Node ID of the created node, EmptyNodeID in case of error
73 */
74 static NodeID add_output_node(Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr accessor = nullptr);
75 /** Adds an activation layer node to the graph
76 *
Isabella Gottardi0ae5de92019-03-14 10:32:11 +000077 * @param[in] g Graph to add the node to
78 * @param[in] params Common node parameters
79 * @param[in] input Input to the activation layer node as a NodeID-Index pair
80 * @param[in] act_info Activation layer information
81 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +000082 *
83 * @return Node ID of the created node, EmptyNodeID in case of error
84 */
Isabella Gottardi0ae5de92019-03-14 10:32:11 +000085 static NodeID add_activation_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info,
Michalis Spyrou18574c12019-06-05 10:51:07 +010086 const QuantizationInfo &out_quant_info = QuantizationInfo());
Georgios Pinitasd8734b52017-12-22 15:27:52 +000087 /** Adds a batch normalization layer node to the graph
88 *
89 * @param[in] g Graph to add the node to
90 * @param[in] params Common node parameters
91 * @param[in] input Input to the batch normalization layer node as a NodeID-Index pair
92 * @param[in] epsilon Epsilon parameter
93 * @param[in] mean_accessor Const Node ID that contains the mean values
94 * @param[in] var_accessor Const Node ID that contains the variance values
95 * @param[in] beta_accessor Const Node ID that contains the beta values. Can be EmptyNodeID
96 * @param[in] gamma_accessor Const Node ID that contains the gamma values. Can be EmptyNodeID
97 *
98 * @return Node ID of the created node, EmptyNodeID in case of error
99 */
100 static NodeID add_batch_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, float epsilon,
101 ITensorAccessorUPtr mean_accessor = nullptr, ITensorAccessorUPtr var_accessor = nullptr,
102 ITensorAccessorUPtr beta_accessor = nullptr, ITensorAccessorUPtr gamma_accessor = nullptr);
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100103 /** Adds a bounding box transform layer node to the graph
104 *
105 * @param[in] g Graph to add the node to
106 * @param[in] params Common node parameters
107 * @param[in] input Input to the bounding box transform layer node as a NodeID-Index pair
108 * @param[in] deltas Deltas input to the bounding box transform layer node as a NodeID-Index pair
109 * @param[in] info Bounding Box Transform information
110 *
111 * @return Node ID of the created node, EmptyNodeID in case of error
112 */
113 static NodeID add_bounding_box_transform_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair deltas, BoundingBoxTransformInfo info);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100114 /** Adds an channel shuffle layer node to the graph
115 *
116 * @param[in] g Graph to add the node to
117 * @param[in] params Common node parameters
118 * @param[in] input Input to the activation layer node as a NodeID-Index pair
119 * @param[in] num_groups Number of groups
120 *
121 * @return Node ID of the created node, EmptyNodeID in case of error
122 */
123 static NodeID add_channel_shuffle_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_groups);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000124 /** Adds a convolution layer node to the graph
125 *
Giorgio Arena59631a12018-05-02 13:59:04 +0100126 * TODO (COMPMID-1113): Add a graph descriptor for convolution layer node
127 *
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000128 * @param[in] g Graph to add the node to
129 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000130 * @param[in] input Input to the convolution layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000131 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
132 * @param[in] depth Number of convolution kernels
133 * @param[in] conv_info Convolution layer information
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000134 * @param[in] num_groups (Optional) Number of groups for a grouped convolution. Defaults to 1
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000135 * @param[in] method (Optional) Convolution method to use
Giorgio Arena59631a12018-05-02 13:59:04 +0100136 * @param[in] fast_math_hint (Optional) Fast math hint
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000137 * @param[in] weights_accessor (Optional) Accessor of the weights node data
138 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100139 * @param[in] weights_quant_info (Optional) Weights quantization info
140 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000141 *
142 * @return Node ID of the created node, EmptyNodeID in case of error
143 */
144 static NodeID add_convolution_node(Graph &g, NodeParams params, NodeIdxPair input,
Georgios Pinitase2220552018-07-20 13:23:44 +0100145 Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo conv_info, unsigned int num_groups = 1,
146 ConvolutionMethod method = ConvolutionMethod::Default, FastMathHint fast_math_hint = FastMathHint::Disabled,
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100147 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr,
Michalis Spyrou18574c12019-06-05 10:51:07 +0100148 const QuantizationInfo &weights_quant_info = QuantizationInfo(),
149 const QuantizationInfo &out_quant_info = QuantizationInfo());
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100150 /** Adds a deconvolution layer node to the graph
151 *
152 * @param[in] g Graph to add the node to
153 * @param[in] params Common node parameters
154 * @param[in] input Input to the convolution layer node as a NodeID-Index pair
155 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
156 * @param[in] depth Number of convolution kernels
157 * @param[in] deconv_info Convolution layer information
158 * @param[in] inner_border Inner border (right, top)
159 * @param[in] weights_accessor (Optional) Accessor of the weights node data
160 * @param[in] bias_accessor (Optional) Accessor of the bias node data
161 *
162 * @return Node ID of the created node, EmptyNodeID in case of error
163 */
164 static NodeID add_deconvolution_node(Graph &g, NodeParams params, NodeIdxPair input,
165 Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo deconv_info, Size2D inner_border,
166 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000167 /** Adds a depth concatenate node to the graph
168 *
Isabella Gottardi0ae5de92019-03-14 10:32:11 +0000169 * @param[in] g Graph to add the node to
170 * @param[in] params Common node parameters
Michele Di Giorgioec699752019-03-22 15:25:32 +0000171 * @param[in] inputs Inputs to the concatenate layer node as a NodeID-Index pair
Isabella Gottardi0ae5de92019-03-14 10:32:11 +0000172 * @param[in] concat_descriptor Concatenation layer descriptor
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000173 *
174 * @return Node ID of the created node, EmptyNodeID in case of error
175 */
Michalis Spyrou18574c12019-06-05 10:51:07 +0100176 static NodeID add_concatenate_node(Graph &g, NodeParams params, const std::vector<NodeIdxPair> &inputs, const descriptors::ConcatLayerDescriptor &concat_descriptor);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000177 /** Adds a depth-wise convolution layer node to the graph
178 *
179 * @param[in] g Graph to add the node to
180 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000181 * @param[in] input Input to the depthwise convolution layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000182 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
183 * @param[in] conv_info Convolution layer information
Georgios Pinitas05045c12018-12-07 18:31:47 +0000184 * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000185 * @param[in] method (Optional) Convolution method to use
186 * @param[in] weights_accessor (Optional) Accessor of the weights node data
187 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100188 * @param[in] quant_info (Optional) Weights quantization info
Isabella Gottardi0ae5de92019-03-14 10:32:11 +0000189 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000190 *
191 * @return Node ID of the created node, EmptyNodeID in case of error
192 */
193 static NodeID add_depthwise_convolution_node(Graph &g, NodeParams params, NodeIdxPair input,
Georgios Pinitas05045c12018-12-07 18:31:47 +0000194 Size2D kernel_spatial_extend, PadStrideInfo conv_info, int depth_multiplier = 1,
Georgios Pinitase2220552018-07-20 13:23:44 +0100195 DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default,
Michalis Spyrou18574c12019-06-05 10:51:07 +0100196 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr, const QuantizationInfo &quant_info = QuantizationInfo(),
197 const QuantizationInfo &out_quant_info = QuantizationInfo());
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000198 /** Adds an element-wise layer node to the graph
199 *
200 * @param[in] g Graph to add the node to
201 * @param[in] params Common node parameters
202 * @param[in] input0 First input to the element-wise operation layer node as a NodeID-Index pair
203 * @param[in] input1 Second input to the element-wise operation layer node as a NodeID-Index pair
204 * @param[in] operation Element-wise operation to perform
205 *
206 * @return Node ID of the created node, EmptyNodeID in case of error
207 */
208 static NodeID add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation);
Isabella Gottardi7234ed82018-11-27 08:51:10 +0000209 /** Adds a detection output layer node to the graph
210 *
211 * @param[in] g Graph to add the node to
212 * @param[in] params Common node parameters
213 * @param[in] input_loc Location input to the detection output layer node as a NodeID-Index pair
214 * @param[in] input_conf Confidence input to the detection output layer node as a NodeID-Index pair
215 * @param[in] input_priorbox PriorBox input to the detection output layer node as a NodeID-Index pair
216 * @param[in] detect_info Detection output layer parameters
217 *
218 * @return Node ID of the created node, EmptyNodeID in case of error
219 */
Georgios Pinitasf52cd782019-03-25 14:06:14 +0000220 static NodeID add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, const DetectionOutputLayerInfo &detect_info);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100221 /** Adds a Dummy node to the graph
222 *
223 * @note this node if for debugging purposes. Just alters the shape of the graph pipeline as requested.
224 *
225 * @param[in] g Graph to add the node to
226 * @param[in] params Common node parameters
227 * @param[in] input Input to the dummy node as a NodeID-Index pair
228 * @param[in] shape Output shape
229 *
230 * @return Node ID of the created node, EmptyNodeID in case of error
231 */
232 static NodeID add_dummy_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000233 /** Adds a flatten layer node to the graph
234 *
235 * @param[in] g Graph to add the node to
236 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000237 * @param[in] input Input to the flatten layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000238 *
239 * @return Node ID of the created node, EmptyNodeID in case of error
240 */
241 static NodeID add_flatten_node(Graph &g, NodeParams params, NodeIdxPair input);
242 /** Adds a fully connected layer node to the graph
243 *
Michele Di Giorgioa42f55f2019-03-08 14:52:17 +0000244 * @param[in] g Graph to add the layer to
245 * @param[in] params Common node parameters
246 * @param[in] input Input to the fully connected layer node as a NodeID-Index pair
247 * @param[in] num_outputs Number of output neurons
248 * @param[in] weights_nid Node ID of the weights node data
249 * @param[in] bias_nid (Optional) Node ID of the bias node data. Defaults to EmptyNodeID
250 * @param[in] fc_info (Optional) Fully connected layer metadata
251 * @param[in] out_quant_info (Optional) Output quantization info
252 *
253 * @return Node ID of the created node, EmptyNodeID in case of error
254 */
255 static NodeID add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs,
256 NodeID weights_nid, NodeID bias_nid = EmptyNodeID,
257 const FullyConnectedLayerInfo fc_info = FullyConnectedLayerInfo(),
Michalis Spyrou18574c12019-06-05 10:51:07 +0100258 const QuantizationInfo &out_quant_info = QuantizationInfo());
Michele Di Giorgioa42f55f2019-03-08 14:52:17 +0000259 /** Adds a fully connected layer node to the graph
260 *
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100261 * @param[in] g Graph to add the layer to
262 * @param[in] params Common node parameters
263 * @param[in] input Input to the fully connected layer node as a NodeID-Index pair
264 * @param[in] num_outputs Number of output neurons
265 * @param[in] weights_accessor (Optional) Accessor of the weights node data
266 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Georgios Pinitasc55cef12018-08-01 15:24:18 +0100267 * @param[in] fc_info (Optional) Fully connected layer metadata
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100268 * @param[in] weights_quant_info (Optional) Weights quantization info
269 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000270 *
271 * @return Node ID of the created node, EmptyNodeID in case of error
272 */
273 static NodeID add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs,
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100274 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr,
Georgios Pinitasc55cef12018-08-01 15:24:18 +0100275 const FullyConnectedLayerInfo fc_info = FullyConnectedLayerInfo(),
Michalis Spyrou18574c12019-06-05 10:51:07 +0100276 const QuantizationInfo &weights_quant_info = QuantizationInfo(),
277 const QuantizationInfo &out_quant_info = QuantizationInfo());
Manuel Bottini5209be52019-02-13 16:34:56 +0000278 /** Adds a generate proposals layer node to the graph
279 *
280 * @param[in] g Graph to add the layer to
281 * @param[in] params Common node parameters
282 * @param[in] scores Input scores to the generate proposals layer node as a NodeID-Index pair
283 * @param[in] deltas Input deltas to the generate proposals layer node as a NodeID-Index pair
284 * @param[in] anchors Input anchors to the generate proposals layer node as a NodeID-Index pair
285 * @param[in] info Generate proposals operation information
286 *
287 * @return Node ID of the created node, EmptyNodeID in case of error
288 */
289 static NodeID add_generate_proposals_node(Graph &g, NodeParams params, NodeIdxPair scores, NodeIdxPair deltas,
290 NodeIdxPair anchors, GenerateProposalsInfo info);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000291 /** Adds a normalization layer node to the graph
292 *
293 * @param[in] g Graph to add the node to
294 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000295 * @param[in] input Input to the normalization layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000296 * @param[in] norm_info Normalization layer information
297 *
298 * @return Node ID of the created node, EmptyNodeID in case of error
299 */
300 static NodeID add_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, NormalizationLayerInfo norm_info);
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100301 /** Adds a normalize planar YUV layer node to the graph
302 *
303 * @param[in] g Graph to add the node to
304 * @param[in] params Common node parameters
305 * @param[in] input Input to the normalize planar YUV layer node as a NodeID-Index pair
306 * @param[in] mean_accessor Const Node ID that contains the mean values
307 * @param[in] std_accessor Const Node ID that contains the variance values
308 *
309 * @return Node ID of the created node, EmptyNodeID in case of error
310 */
311 static NodeID add_normalize_planar_yuv_node(Graph &g, NodeParams params, NodeIdxPair input,
312 ITensorAccessorUPtr mean_accessor = nullptr, ITensorAccessorUPtr std_accessor = nullptr);
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100313 /** Adds a pad layer node to the graph
314 *
315 * @param[in] g Graph to add the node to
316 * @param[in] params Common node parameters
317 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
318 * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
319 * specifies the front and the end padding in the i-th dimension.
320 *
321 * @return Node ID of the created node, EmptyNodeID in case of error
322 */
323 static NodeID add_pad_node(Graph &g, NodeParams params, NodeIdxPair input, PaddingList padding);
Georgios Pinitas57c48242018-08-02 13:41:49 +0100324 /** Adds a permute layer node to the graph
325 *
326 * @param[in] g Graph to add the node to
327 * @param[in] params Common node parameters
328 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
329 * @param[in] perm Permutation vector
330 * @param[in] layout (Optional) Data layout to assign to permuted tensor.
331 * If UNKNOWN then the input's layout will be used.
332 *
333 * @return Node ID of the created node, EmptyNodeID in case of error
334 */
335 static NodeID add_permute_node(Graph &g, NodeParams params, NodeIdxPair input, PermutationVector perm, DataLayout layout = DataLayout::UNKNOWN);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000336 /** Adds a pooling layer node to the graph
337 *
338 * @param[in] g Graph to add the node to
339 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000340 * @param[in] input Input to the pooling layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000341 * @param[in] pool_info Pooling layer information
342 *
343 * @return Node ID of the created node, EmptyNodeID in case of error
344 */
345 static NodeID add_pooling_node(Graph &g, NodeParams params, NodeIdxPair input, PoolingLayerInfo pool_info);
Pablo Tello32521432018-11-15 14:43:10 +0000346 /** Adds a priorbox layer node to the graph
347 *
348 * @param[in] g Graph to add the node to
349 * @param[in] params Common node parameters
350 * @param[in] input0 First input to the priorbox layer node as a NodeID-Index pair
351 * @param[in] input1 Second input to the priorbox layer node as a NodeID-Index pair
352 * @param[in] prior_info PriorBox parameters
353 *
354 * @return Node ID of the created node, EmptyNodeID in case of error
355 */
Georgios Pinitasf52cd782019-03-25 14:06:14 +0000356 static NodeID add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, const PriorBoxLayerInfo &prior_info);
Isabella Gottardi3db1ba92019-05-17 12:35:20 +0100357 /** Adds a quantization layer node to the graph
358 *
359 * @param[in] g Graph to add the node to
360 * @param[in] params Common node parameters
361 * @param[in] input Input to the quantization layer node as a NodeID-Index pair
362 * @param[in] out_quant_info Output quantization info
363 *
364 * @return Node ID of the created node, EmptyNodeID in case of error
365 */
Michalis Spyrou18574c12019-06-05 10:51:07 +0100366 static NodeID add_quantization_node(Graph &g, NodeParams params, NodeIdxPair input, const QuantizationInfo &out_quant_info);
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100367 /** Adds a reorg layer node to the graph
368 *
369 * @param[in] g Graph to add the node to
370 * @param[in] params Common node parameters
371 * @param[in] input Input to the reorg layer node as a NodeID-Index pair
372 * @param[in] stride Stride value to use for reorganizing the values in the output tensor.
373 *
374 * @return Node ID of the created node, EmptyNodeID in case of error
375 */
376 static NodeID add_reorg_node(Graph &g, NodeParams params, NodeIdxPair input, int stride);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000377 /** Adds a reshape layer node to the graph
378 *
379 * @param[in] g Graph to add the node to
380 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000381 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000382 * @param[in] shape Output reshaped shape
383 *
384 * @return Node ID of the created node, EmptyNodeID in case of error
385 */
386 static NodeID add_reshape_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100387 /** Adds a resize layer node to the graph
388 *
389 * @param[in] g Graph to add the node to
390 * @param[in] params Common node parameters
391 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
392 * @param[in] policy Interpolation policy
393 * @param[in] width_scale Width scaling factor
394 * @param[in] height_scale Height scaling factor
395 *
396 * @return Node ID of the created node, EmptyNodeID in case of error
397 */
398 static NodeID add_resize_node(Graph &g, NodeParams params, NodeIdxPair input, InterpolationPolicy policy, float width_scale, float height_scale);
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100399 /** Adds a ROI align layer node to the graph
400 *
401 * @param[in] g Graph to add the node to
402 * @param[in] params Common node parameters
403 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
Manuel Bottinicc5171b2019-01-09 17:04:39 +0000404 * @param[in] rois Input containing the ROIs.
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100405 * @param[in] pool_info Contains pooling operation information described in @ref ROIPoolingLayerInfo.
406 *
407 * @return Node ID of the created node, EmptyNodeID in case of error
408 */
409 static NodeID add_roi_align_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair rois, ROIPoolingLayerInfo pool_info);
Isabella Gottardi88d5b222018-04-06 12:24:55 +0100410 /** Adds a scale layer node to the graph
411 * This layer computes a product of the input with a scale (read from mul_accessor) and it applies an offset (read from add_accessor).
412 * output = input * mul_w + add_w
413 *
414 * @param[in] g Graph to add the layer to
415 * @param[in] params Common node parameters
416 * @param[in] input Input to the fully connected layer node as a NodeID-Index pair
417 * @param[in] mul_accessor (Optional) Accessor of the mul node data
418 * @param[in] add_accessor (Optional) Accessor of the add node data
419 *
420 * @return Node ID of the created node, EmptyNodeID in case of error
421 */
422 static NodeID add_scale_layer(Graph &g, const NodeParams &params, NodeIdxPair input,
423 ITensorAccessorUPtr mul_accessor = nullptr, ITensorAccessorUPtr add_accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000424 /** Adds a softmax node to the graph
425 *
426 * @param[in] g Graph to add the node to
427 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000428 * @param[in] input Input to the softmax layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000429 * @param[in] beta Beta parameter
430 *
431 * @return Node ID of the created node, EmptyNodeID in case of error
432 */
433 static NodeID add_softmax_node(Graph &g, NodeParams params, NodeIdxPair input, float beta = 1.f);
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100434 /** Adds a slice node to the graph
435 *
436 * @param[in] g Graph to add the node to
437 * @param[in] params Common node parameters
438 * @param[in] input Input to the slice layer node as a NodeID-Index pair
439 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
440 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
441 *
442 * @return Node ID of the created node, EmptyNodeID in case of error
443 */
444 static NodeID add_slice_node(Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends);
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000445 /** Adds a split node to the graph
446 *
447 * @param[in] g Graph to add the node to
448 * @param[in] params Common node parameters
449 * @param[in] input Input to the split layer node as a NodeID-Index pair
450 * @param[in] num_splits Number of different splits
451 * @param[in] axis (Optional) Split axis. Defaults to 0
452 *
453 * @return Node ID of the created node, EmptyNodeID in case of error
454 */
455 static NodeID add_split_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis = 0);
Michele Di Giorgioec699752019-03-22 15:25:32 +0000456 /** Adds a stack layer node to the graph
457 *
458 * @param[in] g Graph to add the node to
459 * @param[in] params Common node parameters
460 * @param[in] inputs Inputs to the reorg layer node as a NodeID-Index pair
461 * @param[in] axis Axis along which the input tensors have to be packed
462 *
463 * @return Node ID of the created node, EmptyNodeID in case of error
464 */
465 static NodeID add_stack_node(Graph &g, NodeParams params, const std::vector<NodeIdxPair> &inputs, int axis);
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100466 /** Adds an upsample layer to the graph
467 *
468 * @param[in] g Graph to add the node to
469 * @param[in] params Common node parameters
470 * @param[in] input Input to the yolo layer node as a NodeID-Index pair
471 * @param[in] info Upsample layer stride info
472 * @param[in] upsampling_policy Upsampling policy used
473 *
474 * @return Node ID of the created node, EmptyNodeID in case of error
475 */
476 static NodeID add_upsample_node(Graph &g, NodeParams params, NodeIdxPair input, Size2D info, InterpolationPolicy upsampling_policy);
Michalis Spyrou96f67692018-09-13 11:39:28 +0100477 /** Adds a yolo layer to the graph
478 *
479 * @param[in] g Graph to add the node to
480 * @param[in] params Common node parameters
481 * @param[in] input Input to the yolo layer node as a NodeID-Index pair
482 * @param[in] act_info Activation layer parameters
483 * @param[in] num_classes Number of classes to activate
484 *
485 * @return Node ID of the created node, EmptyNodeID in case of error
486 */
487 static NodeID add_yolo_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info, int32_t num_classes);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000488};
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100489} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000490} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100491#endif /* __ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H__ */