blob: cb905e700e55ba41fea757113e0056c1c5809e23 [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
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"
28#include "arm_compute/graph/Types.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000029
30namespace arm_compute
31{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010032namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000033{
34// Forward declaration
35class Graph;
36
37/** Graph builder class
38 *
39 * Builds and compiles a graph
40 */
41class GraphBuilder final
42{
43public:
44 /** Adds a Const node to the graph
45 *
46 * @param[in] g Graph to add the node to
47 * @param[in] params Common node parameters
48 * @param[in] desc Tensor descriptor of the node
49 * @param[in] accessor (Optional) Accessor of the const node data
50 *
51 * @return Node ID of the created node, EmptyNodeID in case of error
52 */
53 static NodeID add_const_node(Graph &g, NodeParams params, TensorDescriptor desc, ITensorAccessorUPtr accessor = nullptr);
54 /** Adds an input layer node to the graph
55 *
56 * @param[in] g Graph to add the node to
57 * @param[in] params Common node parameters
58 * @param[in] desc Tensor descriptor of the Tensor
59 * @param[in] accessor (Optional) Accessor of the input node data
60 *
61 * @return Node ID of the created node, EmptyNodeID in case of error
62 */
63 static NodeID add_input_node(Graph &g, NodeParams params, TensorDescriptor desc, ITensorAccessorUPtr accessor = nullptr);
64 /** Adds an output layer node to the graph
65 *
66 * @param[in] g Graph to add the node to
67 * @param[in] params Common node parameters
68 * @param[in] input Input to the output node as a NodeID-Index pair
69 * @param[in] accessor (Optional) Accessor of the output node data
70 *
71 * @return Node ID of the created node, EmptyNodeID in case of error
72 */
73 static NodeID add_output_node(Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr accessor = nullptr);
74 /** Adds an activation layer node to the graph
75 *
76 * @param[in] g Graph to add the node to
77 * @param[in] params Common node parameters
78 * @param[in] input Input to the activation layer node as a NodeID-Index pair
79 * @param[in] act_info Activation layer information
80 *
81 * @return Node ID of the created node, EmptyNodeID in case of error
82 */
83 static NodeID add_activation_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info);
84 /** Adds a batch normalization layer node to the graph
85 *
86 * @param[in] g Graph to add the node to
87 * @param[in] params Common node parameters
88 * @param[in] input Input to the batch normalization layer node as a NodeID-Index pair
89 * @param[in] epsilon Epsilon parameter
90 * @param[in] mean_accessor Const Node ID that contains the mean values
91 * @param[in] var_accessor Const Node ID that contains the variance values
92 * @param[in] beta_accessor Const Node ID that contains the beta values. Can be EmptyNodeID
93 * @param[in] gamma_accessor Const Node ID that contains the gamma values. Can be EmptyNodeID
94 *
95 * @return Node ID of the created node, EmptyNodeID in case of error
96 */
97 static NodeID add_batch_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, float epsilon,
98 ITensorAccessorUPtr mean_accessor = nullptr, ITensorAccessorUPtr var_accessor = nullptr,
99 ITensorAccessorUPtr beta_accessor = nullptr, ITensorAccessorUPtr gamma_accessor = nullptr);
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100100 /** Adds a bounding box transform layer node to the graph
101 *
102 * @param[in] g Graph to add the node to
103 * @param[in] params Common node parameters
104 * @param[in] input Input to the bounding box transform layer node as a NodeID-Index pair
105 * @param[in] deltas Deltas input to the bounding box transform layer node as a NodeID-Index pair
106 * @param[in] info Bounding Box Transform information
107 *
108 * @return Node ID of the created node, EmptyNodeID in case of error
109 */
110 static NodeID add_bounding_box_transform_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair deltas, BoundingBoxTransformInfo info);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100111 /** Adds an channel shuffle layer node to the graph
112 *
113 * @param[in] g Graph to add the node to
114 * @param[in] params Common node parameters
115 * @param[in] input Input to the activation layer node as a NodeID-Index pair
116 * @param[in] num_groups Number of groups
117 *
118 * @return Node ID of the created node, EmptyNodeID in case of error
119 */
120 static NodeID add_channel_shuffle_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_groups);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000121 /** Adds a convolution layer node to the graph
122 *
Giorgio Arena59631a12018-05-02 13:59:04 +0100123 * TODO (COMPMID-1113): Add a graph descriptor for convolution layer node
124 *
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000125 * @param[in] g Graph to add the node to
126 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000127 * @param[in] input Input to the convolution layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000128 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
129 * @param[in] depth Number of convolution kernels
130 * @param[in] conv_info Convolution layer information
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000131 * @param[in] num_groups (Optional) Number of groups for a grouped convolution. Defaults to 1
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000132 * @param[in] method (Optional) Convolution method to use
Giorgio Arena59631a12018-05-02 13:59:04 +0100133 * @param[in] fast_math_hint (Optional) Fast math hint
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000134 * @param[in] weights_accessor (Optional) Accessor of the weights node data
135 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100136 * @param[in] weights_quant_info (Optional) Weights quantization info
137 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000138 *
139 * @return Node ID of the created node, EmptyNodeID in case of error
140 */
141 static NodeID add_convolution_node(Graph &g, NodeParams params, NodeIdxPair input,
Georgios Pinitase2220552018-07-20 13:23:44 +0100142 Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo conv_info, unsigned int num_groups = 1,
143 ConvolutionMethod method = ConvolutionMethod::Default, FastMathHint fast_math_hint = FastMathHint::Disabled,
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100144 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr,
145 const QuantizationInfo weights_quant_info = QuantizationInfo(),
146 const QuantizationInfo out_quant_info = QuantizationInfo());
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100147 /** Adds a deconvolution layer node to the graph
148 *
149 * @param[in] g Graph to add the node to
150 * @param[in] params Common node parameters
151 * @param[in] input Input to the convolution layer node as a NodeID-Index pair
152 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
153 * @param[in] depth Number of convolution kernels
154 * @param[in] deconv_info Convolution layer information
155 * @param[in] inner_border Inner border (right, top)
156 * @param[in] weights_accessor (Optional) Accessor of the weights node data
157 * @param[in] bias_accessor (Optional) Accessor of the bias node data
158 *
159 * @return Node ID of the created node, EmptyNodeID in case of error
160 */
161 static NodeID add_deconvolution_node(Graph &g, NodeParams params, NodeIdxPair input,
162 Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo deconv_info, Size2D inner_border,
163 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000164 /** Adds a depth concatenate node to the graph
165 *
166 * @param[in] g Graph to add the node to
167 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000168 * @param[in] inputs Inputs to the depth concatenate layer node as a NodeID-Index pair
Georgios Pinitase2220552018-07-20 13:23:44 +0100169 * @param[in] axis Concatenation axis
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000170 *
171 * @return Node ID of the created node, EmptyNodeID in case of error
172 */
Georgios Pinitase2220552018-07-20 13:23:44 +0100173 static NodeID add_concatenate_node(Graph &g, NodeParams params, std::vector<NodeIdxPair> inputs, DataLayoutDimension axis);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000174 /** Adds a depth-wise convolution layer node to the graph
175 *
176 * @param[in] g Graph to add the node to
177 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000178 * @param[in] input Input to the depthwise convolution layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000179 * @param[in] kernel_spatial_extend Spatial extend of convolution kernels
180 * @param[in] conv_info Convolution layer information
Georgios Pinitas05045c12018-12-07 18:31:47 +0000181 * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000182 * @param[in] method (Optional) Convolution method to use
183 * @param[in] weights_accessor (Optional) Accessor of the weights node data
184 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100185 * @param[in] quant_info (Optional) Weights quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000186 *
187 * @return Node ID of the created node, EmptyNodeID in case of error
188 */
189 static NodeID add_depthwise_convolution_node(Graph &g, NodeParams params, NodeIdxPair input,
Georgios Pinitas05045c12018-12-07 18:31:47 +0000190 Size2D kernel_spatial_extend, PadStrideInfo conv_info, int depth_multiplier = 1,
Georgios Pinitase2220552018-07-20 13:23:44 +0100191 DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default,
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100192 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr, const QuantizationInfo quant_info = QuantizationInfo());
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000193 /** Adds an element-wise layer node to the graph
194 *
195 * @param[in] g Graph to add the node to
196 * @param[in] params Common node parameters
197 * @param[in] input0 First input to the element-wise operation layer node as a NodeID-Index pair
198 * @param[in] input1 Second input to the element-wise operation layer node as a NodeID-Index pair
199 * @param[in] operation Element-wise operation to perform
200 *
201 * @return Node ID of the created node, EmptyNodeID in case of error
202 */
203 static NodeID add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation);
Isabella Gottardi7234ed82018-11-27 08:51:10 +0000204 /** Adds a detection output layer node to the graph
205 *
206 * @param[in] g Graph to add the node to
207 * @param[in] params Common node parameters
208 * @param[in] input_loc Location input to the detection output layer node as a NodeID-Index pair
209 * @param[in] input_conf Confidence input to the detection output layer node as a NodeID-Index pair
210 * @param[in] input_priorbox PriorBox input to the detection output layer node as a NodeID-Index pair
211 * @param[in] detect_info Detection output layer parameters
212 *
213 * @return Node ID of the created node, EmptyNodeID in case of error
214 */
215 static NodeID add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, DetectionOutputLayerInfo detect_info);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100216 /** Adds a Dummy node to the graph
217 *
218 * @note this node if for debugging purposes. Just alters the shape of the graph pipeline as requested.
219 *
220 * @param[in] g Graph to add the node to
221 * @param[in] params Common node parameters
222 * @param[in] input Input to the dummy node as a NodeID-Index pair
223 * @param[in] shape Output shape
224 *
225 * @return Node ID of the created node, EmptyNodeID in case of error
226 */
227 static NodeID add_dummy_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000228 /** Adds a flatten layer node to the graph
229 *
230 * @param[in] g Graph to add the node to
231 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000232 * @param[in] input Input to the flatten layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000233 *
234 * @return Node ID of the created node, EmptyNodeID in case of error
235 */
236 static NodeID add_flatten_node(Graph &g, NodeParams params, NodeIdxPair input);
237 /** Adds a fully connected layer node to the graph
238 *
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100239 * @param[in] g Graph to add the layer to
240 * @param[in] params Common node parameters
241 * @param[in] input Input to the fully connected layer node as a NodeID-Index pair
242 * @param[in] num_outputs Number of output neurons
243 * @param[in] weights_accessor (Optional) Accessor of the weights node data
244 * @param[in] bias_accessor (Optional) Accessor of the bias node data
Georgios Pinitasc55cef12018-08-01 15:24:18 +0100245 * @param[in] fc_info (Optional) Fully connected layer metadata
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100246 * @param[in] weights_quant_info (Optional) Weights quantization info
247 * @param[in] out_quant_info (Optional) Output quantization info
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000248 *
249 * @return Node ID of the created node, EmptyNodeID in case of error
250 */
251 static NodeID add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs,
Georgios Pinitas2f1366a2018-07-31 16:33:06 +0100252 ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr,
Georgios Pinitasc55cef12018-08-01 15:24:18 +0100253 const FullyConnectedLayerInfo fc_info = FullyConnectedLayerInfo(),
254 const QuantizationInfo weights_quant_info = QuantizationInfo(),
255 const QuantizationInfo out_quant_info = QuantizationInfo());
Michele Di Giorgio47e6fed2018-11-13 12:04:25 +0000256 /** Adds a generate proposals layer node to the graph
257 *
258 * @param[in] g Graph to add the layer to
259 * @param[in] params Common node parameters
260 * @param[in] scores Input scores to the generate proposals layer node as a NodeID-Index pair
261 * @param[in] deltas Input deltas to the generate proposals layer node as a NodeID-Index pair
262 * @param[in] anchors Input anchors to the generate proposals layer node as a NodeID-Index pair
263 * @param[in] info Generate proposals operation information
264 *
265 * @return Node ID of the created node, EmptyNodeID in case of error
266 */
267 static NodeID add_generate_proposals_node(Graph &g, NodeParams params, NodeIdxPair scores, NodeIdxPair deltas,
268 NodeIdxPair anchors, GenerateProposalsInfo info);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000269 /** Adds a normalization layer node to the graph
270 *
271 * @param[in] g Graph to add the node to
272 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000273 * @param[in] input Input to the normalization layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000274 * @param[in] norm_info Normalization layer information
275 *
276 * @return Node ID of the created node, EmptyNodeID in case of error
277 */
278 static NodeID add_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, NormalizationLayerInfo norm_info);
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100279 /** Adds a normalize planar YUV layer node to the graph
280 *
281 * @param[in] g Graph to add the node to
282 * @param[in] params Common node parameters
283 * @param[in] input Input to the normalize planar YUV layer node as a NodeID-Index pair
284 * @param[in] mean_accessor Const Node ID that contains the mean values
285 * @param[in] std_accessor Const Node ID that contains the variance values
286 *
287 * @return Node ID of the created node, EmptyNodeID in case of error
288 */
289 static NodeID add_normalize_planar_yuv_node(Graph &g, NodeParams params, NodeIdxPair input,
290 ITensorAccessorUPtr mean_accessor = nullptr, ITensorAccessorUPtr std_accessor = nullptr);
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100291 /** Adds a pad layer node to the graph
292 *
293 * @param[in] g Graph to add the node to
294 * @param[in] params Common node parameters
295 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
296 * @param[in] padding The padding for each spatial dimension of the input tensor. The pair padding[i]
297 * specifies the front and the end padding in the i-th dimension.
298 *
299 * @return Node ID of the created node, EmptyNodeID in case of error
300 */
301 static NodeID add_pad_node(Graph &g, NodeParams params, NodeIdxPair input, PaddingList padding);
Georgios Pinitas57c48242018-08-02 13:41:49 +0100302 /** Adds a permute layer node to the graph
303 *
304 * @param[in] g Graph to add the node to
305 * @param[in] params Common node parameters
306 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
307 * @param[in] perm Permutation vector
308 * @param[in] layout (Optional) Data layout to assign to permuted tensor.
309 * If UNKNOWN then the input's layout will be used.
310 *
311 * @return Node ID of the created node, EmptyNodeID in case of error
312 */
313 static NodeID add_permute_node(Graph &g, NodeParams params, NodeIdxPair input, PermutationVector perm, DataLayout layout = DataLayout::UNKNOWN);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000314 /** Adds a pooling layer node to the graph
315 *
316 * @param[in] g Graph to add the node to
317 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000318 * @param[in] input Input to the pooling layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000319 * @param[in] pool_info Pooling layer information
320 *
321 * @return Node ID of the created node, EmptyNodeID in case of error
322 */
323 static NodeID add_pooling_node(Graph &g, NodeParams params, NodeIdxPair input, PoolingLayerInfo pool_info);
Pablo Tello32521432018-11-15 14:43:10 +0000324 /** Adds a priorbox 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] input0 First input to the priorbox layer node as a NodeID-Index pair
329 * @param[in] input1 Second input to the priorbox layer node as a NodeID-Index pair
330 * @param[in] prior_info PriorBox parameters
331 *
332 * @return Node ID of the created node, EmptyNodeID in case of error
333 */
334 static NodeID add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, PriorBoxLayerInfo prior_info);
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100335 /** Adds a reorg layer node to the graph
336 *
337 * @param[in] g Graph to add the node to
338 * @param[in] params Common node parameters
339 * @param[in] input Input to the reorg layer node as a NodeID-Index pair
340 * @param[in] stride Stride value to use for reorganizing the values in the output tensor.
341 *
342 * @return Node ID of the created node, EmptyNodeID in case of error
343 */
344 static NodeID add_reorg_node(Graph &g, NodeParams params, NodeIdxPair input, int stride);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000345 /** Adds a reshape layer node to the graph
346 *
347 * @param[in] g Graph to add the node to
348 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000349 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000350 * @param[in] shape Output reshaped shape
351 *
352 * @return Node ID of the created node, EmptyNodeID in case of error
353 */
354 static NodeID add_reshape_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape);
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100355 /** Adds a resize layer node to the graph
356 *
357 * @param[in] g Graph to add the node to
358 * @param[in] params Common node parameters
359 * @param[in] input Input to the reshape layer node as a NodeID-Index pair
360 * @param[in] policy Interpolation policy
361 * @param[in] width_scale Width scaling factor
362 * @param[in] height_scale Height scaling factor
363 *
364 * @return Node ID of the created node, EmptyNodeID in case of error
365 */
366 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 +0100367 /** Adds a ROI align 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 reshape layer node as a NodeID-Index pair
372 * @param[in] rois Input containing @ref ROI.
373 * @param[in] pool_info Contains pooling operation information described in @ref ROIPoolingLayerInfo.
374 *
375 * @return Node ID of the created node, EmptyNodeID in case of error
376 */
377 static NodeID add_roi_align_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair rois, ROIPoolingLayerInfo pool_info);
Isabella Gottardi88d5b222018-04-06 12:24:55 +0100378 /** Adds a scale layer node to the graph
379 * This layer computes a product of the input with a scale (read from mul_accessor) and it applies an offset (read from add_accessor).
380 * output = input * mul_w + add_w
381 *
382 * @param[in] g Graph to add the layer to
383 * @param[in] params Common node parameters
384 * @param[in] input Input to the fully connected layer node as a NodeID-Index pair
385 * @param[in] mul_accessor (Optional) Accessor of the mul node data
386 * @param[in] add_accessor (Optional) Accessor of the add node data
387 *
388 * @return Node ID of the created node, EmptyNodeID in case of error
389 */
390 static NodeID add_scale_layer(Graph &g, const NodeParams &params, NodeIdxPair input,
391 ITensorAccessorUPtr mul_accessor = nullptr, ITensorAccessorUPtr add_accessor = nullptr);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000392 /** Adds a softmax node to the graph
393 *
394 * @param[in] g Graph to add the node to
395 * @param[in] params Common node parameters
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000396 * @param[in] input Input to the softmax layer node as a NodeID-Index pair
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000397 * @param[in] beta Beta parameter
398 *
399 * @return Node ID of the created node, EmptyNodeID in case of error
400 */
401 static NodeID add_softmax_node(Graph &g, NodeParams params, NodeIdxPair input, float beta = 1.f);
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100402 /** Adds a slice node to the graph
403 *
404 * @param[in] g Graph to add the node to
405 * @param[in] params Common node parameters
406 * @param[in] input Input to the slice layer node as a NodeID-Index pair
407 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
408 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
409 *
410 * @return Node ID of the created node, EmptyNodeID in case of error
411 */
412 static NodeID add_slice_node(Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends);
Georgios Pinitasee33ea52018-03-08 16:01:29 +0000413 /** Adds a split node to the graph
414 *
415 * @param[in] g Graph to add the node to
416 * @param[in] params Common node parameters
417 * @param[in] input Input to the split layer node as a NodeID-Index pair
418 * @param[in] num_splits Number of different splits
419 * @param[in] axis (Optional) Split axis. Defaults to 0
420 *
421 * @return Node ID of the created node, EmptyNodeID in case of error
422 */
423 static NodeID add_split_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis = 0);
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100424 /** Adds an upsample layer to the graph
425 *
426 * @param[in] g Graph to add the node to
427 * @param[in] params Common node parameters
428 * @param[in] input Input to the yolo layer node as a NodeID-Index pair
429 * @param[in] info Upsample layer stride info
430 * @param[in] upsampling_policy Upsampling policy used
431 *
432 * @return Node ID of the created node, EmptyNodeID in case of error
433 */
434 static NodeID add_upsample_node(Graph &g, NodeParams params, NodeIdxPair input, Size2D info, InterpolationPolicy upsampling_policy);
Michalis Spyrou96f67692018-09-13 11:39:28 +0100435 /** Adds a yolo layer to the graph
436 *
437 * @param[in] g Graph to add the node to
438 * @param[in] params Common node parameters
439 * @param[in] input Input to the yolo layer node as a NodeID-Index pair
440 * @param[in] act_info Activation layer parameters
441 * @param[in] num_classes Number of classes to activate
442 *
443 * @return Node ID of the created node, EmptyNodeID in case of error
444 */
445 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 +0000446};
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100447} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000448} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100449#endif /* __ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H__ */