Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
Sheri Zhang | 78e7691 | 2021-05-06 10:05:22 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H |
| 25 | #define ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/graph/ITensorAccessor.h" |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 28 | #include "arm_compute/graph/LayerDescriptors.h" |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 29 | #include "arm_compute/graph/Types.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 33 | namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 34 | { |
| 35 | // Forward declaration |
| 36 | class Graph; |
| 37 | |
| 38 | /** Graph builder class |
| 39 | * |
| 40 | * Builds and compiles a graph |
| 41 | */ |
| 42 | class GraphBuilder final |
| 43 | { |
| 44 | public: |
| 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 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 54 | static NodeID |
| 55 | add_const_node(Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor = nullptr); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 56 | /** Adds an input layer node to the graph |
| 57 | * |
| 58 | * @param[in] g Graph to add the node to |
| 59 | * @param[in] params Common node parameters |
| 60 | * @param[in] desc Tensor descriptor of the Tensor |
| 61 | * @param[in] accessor (Optional) Accessor of the input node data |
| 62 | * |
| 63 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 64 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 65 | static NodeID |
| 66 | add_input_node(Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor = nullptr); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 67 | /** Adds an output layer node to the graph |
| 68 | * |
| 69 | * @param[in] g Graph to add the node to |
| 70 | * @param[in] params Common node parameters |
| 71 | * @param[in] input Input to the output node as a NodeID-Index pair |
| 72 | * @param[in] accessor (Optional) Accessor of the output node data |
| 73 | * |
| 74 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 75 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 76 | static NodeID |
| 77 | add_output_node(Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr accessor = nullptr); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 78 | /** Adds an activation layer node to the graph |
| 79 | * |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 80 | * @param[in] g Graph to add the node to |
| 81 | * @param[in] params Common node parameters |
| 82 | * @param[in] input Input to the activation layer node as a NodeID-Index pair |
| 83 | * @param[in] act_info Activation layer information |
| 84 | * @param[in] out_quant_info (Optional) Output quantization info |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 85 | * |
| 86 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 87 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 88 | static NodeID add_activation_node(Graph &g, |
| 89 | NodeParams params, |
| 90 | NodeIdxPair input, |
| 91 | ActivationLayerInfo act_info, |
Michalis Spyrou | 18574c1 | 2019-06-05 10:51:07 +0100 | [diff] [blame] | 92 | const QuantizationInfo &out_quant_info = QuantizationInfo()); |
thecha01 | e8f05da | 2020-08-24 17:21:41 +0100 | [diff] [blame] | 93 | /** Adds an activation layer node to the graph |
| 94 | * |
| 95 | * @param[in] g Graph to add the node to |
| 96 | * @param[in] params Common node parameters |
| 97 | * @param[in] input Input to the activation layer node as a NodeID-Index pair |
| 98 | * @param[in] op Reduction Operation: min or max |
| 99 | * @param[in] axis Axis to perform reduction operation across |
| 100 | * @param[in] out_data_type (Optional) Output data type |
| 101 | * @param[in] out_quant_info (Optional) Output quantization info |
| 102 | * |
| 103 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 104 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 105 | static NodeID add_arg_min_max_node(Graph &g, |
| 106 | NodeParams params, |
| 107 | NodeIdxPair input, |
| 108 | ReductionOperation op, |
| 109 | unsigned int axis, |
thecha01 | e8f05da | 2020-08-24 17:21:41 +0100 | [diff] [blame] | 110 | DataType out_data_type = DataType::UNKNOWN, |
| 111 | const QuantizationInfo &out_quant_info = QuantizationInfo()); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 112 | /** Adds a batch normalization layer node to the graph |
| 113 | * |
| 114 | * @param[in] g Graph to add the node to |
| 115 | * @param[in] params Common node parameters |
| 116 | * @param[in] input Input to the batch normalization layer node as a NodeID-Index pair |
| 117 | * @param[in] epsilon Epsilon parameter |
| 118 | * @param[in] mean_accessor Const Node ID that contains the mean values |
| 119 | * @param[in] var_accessor Const Node ID that contains the variance values |
| 120 | * @param[in] beta_accessor Const Node ID that contains the beta values. Can be EmptyNodeID |
| 121 | * @param[in] gamma_accessor Const Node ID that contains the gamma values. Can be EmptyNodeID |
| 122 | * |
| 123 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 124 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 125 | static NodeID add_batch_normalization_node(Graph &g, |
| 126 | NodeParams params, |
| 127 | NodeIdxPair input, |
| 128 | float epsilon, |
| 129 | ITensorAccessorUPtr mean_accessor = nullptr, |
| 130 | ITensorAccessorUPtr var_accessor = nullptr, |
| 131 | ITensorAccessorUPtr beta_accessor = nullptr, |
| 132 | ITensorAccessorUPtr gamma_accessor = nullptr); |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 133 | /** Adds a bounding box transform layer node to the graph |
| 134 | * |
| 135 | * @param[in] g Graph to add the node to |
| 136 | * @param[in] params Common node parameters |
| 137 | * @param[in] input Input to the bounding box transform layer node as a NodeID-Index pair |
| 138 | * @param[in] deltas Deltas input to the bounding box transform layer node as a NodeID-Index pair |
| 139 | * @param[in] info Bounding Box Transform information |
| 140 | * |
| 141 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 142 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 143 | static NodeID add_bounding_box_transform_node( |
| 144 | Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair deltas, BoundingBoxTransformInfo info); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 145 | /** Adds an channel shuffle layer node to the graph |
| 146 | * |
| 147 | * @param[in] g Graph to add the node to |
| 148 | * @param[in] params Common node parameters |
| 149 | * @param[in] input Input to the activation layer node as a NodeID-Index pair |
| 150 | * @param[in] num_groups Number of groups |
| 151 | * |
| 152 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 153 | */ |
| 154 | static NodeID add_channel_shuffle_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_groups); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 155 | /** Adds a convolution layer node to the graph |
| 156 | * |
| 157 | * @param[in] g Graph to add the node to |
| 158 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 159 | * @param[in] input Input to the convolution layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 160 | * @param[in] kernel_spatial_extend Spatial extend of convolution kernels |
| 161 | * @param[in] depth Number of convolution kernels |
| 162 | * @param[in] conv_info Convolution layer information |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 163 | * @param[in] num_groups (Optional) Number of groups for a grouped convolution. Defaults to 1 |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 164 | * @param[in] method (Optional) Convolution method to use |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 165 | * @param[in] fast_math_hint (Optional) Fast math hint |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 166 | * @param[in] weights_accessor (Optional) Accessor of the weights node data |
| 167 | * @param[in] bias_accessor (Optional) Accessor of the bias node data |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 168 | * @param[in] weights_quant_info (Optional) Weights quantization info |
| 169 | * @param[in] out_quant_info (Optional) Output quantization info |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 170 | * |
| 171 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 172 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 173 | static NodeID add_convolution_node(Graph &g, |
| 174 | NodeParams params, |
| 175 | NodeIdxPair input, |
| 176 | Size2D kernel_spatial_extend, |
| 177 | unsigned int depth, |
| 178 | PadStrideInfo conv_info, |
| 179 | unsigned int num_groups = 1, |
| 180 | ConvolutionMethod method = ConvolutionMethod::Default, |
| 181 | FastMathHint fast_math_hint = FastMathHint::Disabled, |
| 182 | ITensorAccessorUPtr weights_accessor = nullptr, |
| 183 | ITensorAccessorUPtr bias_accessor = nullptr, |
Michalis Spyrou | 18574c1 | 2019-06-05 10:51:07 +0100 | [diff] [blame] | 184 | const QuantizationInfo &weights_quant_info = QuantizationInfo(), |
| 185 | const QuantizationInfo &out_quant_info = QuantizationInfo()); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 186 | /** Adds a deconvolution layer node to the graph |
| 187 | * |
| 188 | * @param[in] g Graph to add the node to |
| 189 | * @param[in] params Common node parameters |
| 190 | * @param[in] input Input to the convolution layer node as a NodeID-Index pair |
| 191 | * @param[in] kernel_spatial_extend Spatial extend of convolution kernels |
| 192 | * @param[in] depth Number of convolution kernels |
| 193 | * @param[in] deconv_info Convolution layer information |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 194 | * @param[in] weights_accessor (Optional) Accessor of the weights node data |
| 195 | * @param[in] bias_accessor (Optional) Accessor of the bias node data |
| 196 | * |
| 197 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 198 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 199 | static NodeID add_deconvolution_node(Graph &g, |
| 200 | NodeParams params, |
| 201 | NodeIdxPair input, |
| 202 | Size2D kernel_spatial_extend, |
| 203 | unsigned int depth, |
| 204 | PadStrideInfo deconv_info, |
| 205 | ITensorAccessorUPtr weights_accessor = nullptr, |
| 206 | ITensorAccessorUPtr bias_accessor = nullptr); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 207 | /** Adds a depth concatenate node to the graph |
| 208 | * |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 209 | * @param[in] g Graph to add the node to |
| 210 | * @param[in] params Common node parameters |
Michele Di Giorgio | ec69975 | 2019-03-22 15:25:32 +0000 | [diff] [blame] | 211 | * @param[in] inputs Inputs to the concatenate layer node as a NodeID-Index pair |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 212 | * @param[in] concat_descriptor Concatenation layer descriptor |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 213 | * |
| 214 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 215 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 216 | static NodeID add_concatenate_node(Graph &g, |
| 217 | NodeParams params, |
| 218 | const std::vector<NodeIdxPair> &inputs, |
| 219 | const descriptors::ConcatLayerDescriptor &concat_descriptor); |
thecha01 | 0a05e6a | 2020-08-28 18:40:38 +0100 | [diff] [blame] | 220 | /** Adds an depth to space layer node to the graph |
| 221 | * |
| 222 | * @param[in] g Graph to add the node to |
| 223 | * @param[in] params Common node parameters |
| 224 | * @param[in] input Input to the depth to space layer node as a NodeID-Index pair |
| 225 | * @param[in] block_shape Block shape to reshape tensor with |
| 226 | * |
| 227 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 228 | */ |
| 229 | static NodeID add_depth_to_space_node(Graph &g, NodeParams params, NodeIdxPair input, int32_t block_shape); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 230 | /** Adds a depth-wise convolution layer node to the graph |
| 231 | * |
| 232 | * @param[in] g Graph to add the node to |
| 233 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 234 | * @param[in] input Input to the depthwise convolution layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 235 | * @param[in] kernel_spatial_extend Spatial extend of convolution kernels |
| 236 | * @param[in] conv_info Convolution layer information |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 237 | * @param[in] depth_multiplier (Optional) Depth multiplier parameter. |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 238 | * @param[in] method (Optional) Convolution method to use |
| 239 | * @param[in] weights_accessor (Optional) Accessor of the weights node data |
| 240 | * @param[in] bias_accessor (Optional) Accessor of the bias node data |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 241 | * @param[in] quant_info (Optional) Weights quantization info |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 242 | * @param[in] out_quant_info (Optional) Output quantization info |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 243 | * |
| 244 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 245 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 246 | static NodeID |
| 247 | add_depthwise_convolution_node(Graph &g, |
| 248 | NodeParams params, |
| 249 | NodeIdxPair input, |
| 250 | Size2D kernel_spatial_extend, |
| 251 | PadStrideInfo conv_info, |
| 252 | int depth_multiplier = 1, |
| 253 | DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default, |
| 254 | ITensorAccessorUPtr weights_accessor = nullptr, |
| 255 | ITensorAccessorUPtr bias_accessor = nullptr, |
| 256 | const QuantizationInfo &quant_info = QuantizationInfo(), |
| 257 | const QuantizationInfo &out_quant_info = QuantizationInfo()); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 258 | /** Adds an element-wise layer node to the graph |
| 259 | * |
| 260 | * @param[in] g Graph to add the node to |
| 261 | * @param[in] params Common node parameters |
| 262 | * @param[in] input0 First input to the element-wise operation layer node as a NodeID-Index pair |
| 263 | * @param[in] input1 Second input to the element-wise operation layer node as a NodeID-Index pair |
| 264 | * @param[in] operation Element-wise operation to perform |
| 265 | * |
| 266 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 267 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 268 | static NodeID add_elementwise_node( |
| 269 | Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation); |
Isabella Gottardi | cd4e9ab | 2019-11-05 17:50:27 +0000 | [diff] [blame] | 270 | /** Adds a dequantization node to the graph |
| 271 | * |
| 272 | * @param[in] g Graph to add the node to |
| 273 | * @param[in] params Common node parameters |
| 274 | * @param[in] input Input to the dequantization node as a NodeID-Index pair |
| 275 | * |
| 276 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 277 | */ |
| 278 | static NodeID add_dequantization_node(Graph &g, NodeParams params, NodeIdxPair input); |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 279 | /** Adds a detection output 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_loc Location input to the detection output layer node as a NodeID-Index pair |
| 284 | * @param[in] input_conf Confidence input to the detection output layer node as a NodeID-Index pair |
| 285 | * @param[in] input_priorbox PriorBox input to the detection output layer node as a NodeID-Index pair |
| 286 | * @param[in] detect_info Detection output layer parameters |
| 287 | * |
| 288 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 289 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 290 | static NodeID add_detection_output_node(Graph &g, |
| 291 | NodeParams params, |
| 292 | NodeIdxPair input_loc, |
| 293 | NodeIdxPair input_conf, |
| 294 | NodeIdxPair input_priorbox, |
| 295 | const DetectionOutputLayerInfo &detect_info); |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 296 | /** Adds a detection post process layer node to the graph |
| 297 | * |
| 298 | * @param[in] g Graph to add the node to |
| 299 | * @param[in] params Common node parameters |
| 300 | * @param[in] input_box_encoding Boxes input to the detection output layer node as a NodeID-Index pair |
| 301 | * @param[in] input_class_prediction Class prediction input to the detection output layer node as a NodeID-Index pair |
| 302 | * @param[in] detect_info Detection output layer parameters |
| 303 | * @param[in] anchors_accessor (Optional) Const Node ID that contains the anchor values |
| 304 | * @param[in] anchor_quant_info (Optional) Anchor quantization info |
| 305 | * |
| 306 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 307 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 308 | static NodeID add_detection_post_process_node(Graph &g, |
| 309 | NodeParams params, |
| 310 | NodeIdxPair input_box_encoding, |
| 311 | NodeIdxPair input_class_prediction, |
| 312 | const DetectionPostProcessLayerInfo &detect_info, |
| 313 | ITensorAccessorUPtr anchors_accessor = nullptr, |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 314 | const QuantizationInfo &anchor_quant_info = QuantizationInfo()); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 315 | /** Adds a Dummy node to the graph |
| 316 | * |
| 317 | * @note this node if for debugging purposes. Just alters the shape of the graph pipeline as requested. |
| 318 | * |
| 319 | * @param[in] g Graph to add the node to |
| 320 | * @param[in] params Common node parameters |
| 321 | * @param[in] input Input to the dummy node as a NodeID-Index pair |
| 322 | * @param[in] shape Output shape |
| 323 | * |
| 324 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 325 | */ |
| 326 | static NodeID add_dummy_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 327 | /** Adds a flatten layer node to the graph |
| 328 | * |
| 329 | * @param[in] g Graph to add the node to |
| 330 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 331 | * @param[in] input Input to the flatten layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 332 | * |
| 333 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 334 | */ |
| 335 | static NodeID add_flatten_node(Graph &g, NodeParams params, NodeIdxPair input); |
| 336 | /** Adds a fully connected layer node to the graph |
| 337 | * |
Michele Di Giorgio | a42f55f | 2019-03-08 14:52:17 +0000 | [diff] [blame] | 338 | * @param[in] g Graph to add the layer to |
| 339 | * @param[in] params Common node parameters |
| 340 | * @param[in] input Input to the fully connected layer node as a NodeID-Index pair |
| 341 | * @param[in] num_outputs Number of output neurons |
| 342 | * @param[in] weights_nid Node ID of the weights node data |
| 343 | * @param[in] bias_nid (Optional) Node ID of the bias node data. Defaults to EmptyNodeID |
| 344 | * @param[in] fc_info (Optional) Fully connected layer metadata |
| 345 | * @param[in] out_quant_info (Optional) Output quantization info |
cfRod | f2c022e | 2021-11-05 11:29:53 +0000 | [diff] [blame] | 346 | * @param[in] fast_math_hint (Optional) Fast math hint |
Michele Di Giorgio | a42f55f | 2019-03-08 14:52:17 +0000 | [diff] [blame] | 347 | * |
| 348 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 349 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 350 | static NodeID add_fully_connected_layer(Graph &g, |
| 351 | NodeParams params, |
| 352 | NodeIdxPair input, |
| 353 | unsigned int num_outputs, |
| 354 | NodeID weights_nid, |
| 355 | NodeID bias_nid = EmptyNodeID, |
Michele Di Giorgio | a42f55f | 2019-03-08 14:52:17 +0000 | [diff] [blame] | 356 | const FullyConnectedLayerInfo fc_info = FullyConnectedLayerInfo(), |
cfRod | f2c022e | 2021-11-05 11:29:53 +0000 | [diff] [blame] | 357 | const QuantizationInfo &out_quant_info = QuantizationInfo(), |
| 358 | FastMathHint fast_math_hint = FastMathHint::Disabled); |
Michele Di Giorgio | a42f55f | 2019-03-08 14:52:17 +0000 | [diff] [blame] | 359 | /** Adds a fully connected layer node to the graph |
| 360 | * |
Georgios Pinitas | 2f1366a | 2018-07-31 16:33:06 +0100 | [diff] [blame] | 361 | * @param[in] g Graph to add the layer to |
| 362 | * @param[in] params Common node parameters |
| 363 | * @param[in] input Input to the fully connected layer node as a NodeID-Index pair |
| 364 | * @param[in] num_outputs Number of output neurons |
| 365 | * @param[in] weights_accessor (Optional) Accessor of the weights node data |
| 366 | * @param[in] bias_accessor (Optional) Accessor of the bias node data |
Georgios Pinitas | c55cef1 | 2018-08-01 15:24:18 +0100 | [diff] [blame] | 367 | * @param[in] fc_info (Optional) Fully connected layer metadata |
Georgios Pinitas | 2f1366a | 2018-07-31 16:33:06 +0100 | [diff] [blame] | 368 | * @param[in] weights_quant_info (Optional) Weights quantization info |
| 369 | * @param[in] out_quant_info (Optional) Output quantization info |
cfRod | f2c022e | 2021-11-05 11:29:53 +0000 | [diff] [blame] | 370 | * @param[in] fast_math_hint (Optional) Fast math hint |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 371 | * |
| 372 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 373 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 374 | static NodeID add_fully_connected_layer(Graph &g, |
| 375 | NodeParams params, |
| 376 | NodeIdxPair input, |
| 377 | unsigned int num_outputs, |
| 378 | ITensorAccessorUPtr weights_accessor = nullptr, |
| 379 | ITensorAccessorUPtr bias_accessor = nullptr, |
| 380 | const FullyConnectedLayerInfo fc_info = FullyConnectedLayerInfo(), |
Michalis Spyrou | 18574c1 | 2019-06-05 10:51:07 +0100 | [diff] [blame] | 381 | const QuantizationInfo &weights_quant_info = QuantizationInfo(), |
cfRod | f2c022e | 2021-11-05 11:29:53 +0000 | [diff] [blame] | 382 | const QuantizationInfo &out_quant_info = QuantizationInfo(), |
| 383 | FastMathHint fast_math_hint = FastMathHint::Disabled); |
Manuel Bottini | 5209be5 | 2019-02-13 16:34:56 +0000 | [diff] [blame] | 384 | /** Adds a generate proposals layer node to the graph |
| 385 | * |
| 386 | * @param[in] g Graph to add the layer to |
| 387 | * @param[in] params Common node parameters |
| 388 | * @param[in] scores Input scores to the generate proposals layer node as a NodeID-Index pair |
| 389 | * @param[in] deltas Input deltas to the generate proposals layer node as a NodeID-Index pair |
| 390 | * @param[in] anchors Input anchors to the generate proposals layer node as a NodeID-Index pair |
| 391 | * @param[in] info Generate proposals operation information |
| 392 | * |
| 393 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 394 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 395 | static NodeID add_generate_proposals_node(Graph &g, |
| 396 | NodeParams params, |
| 397 | NodeIdxPair scores, |
| 398 | NodeIdxPair deltas, |
| 399 | NodeIdxPair anchors, |
| 400 | GenerateProposalsInfo info); |
thecha01 | 3603aff | 2020-09-01 14:52:38 +0100 | [diff] [blame] | 401 | /** Adds a L2 Normalize layer node to the graph |
| 402 | * |
| 403 | * @param[in] g Graph to add the node to |
| 404 | * @param[in] params Common node parameters |
| 405 | * @param[in] input Input to the normalization layer node as a NodeID-Index pair |
| 406 | * @param[in] axis Axis to perform normalization on |
| 407 | * @param[in] epsilon Lower bound value for the normalization |
| 408 | * |
| 409 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 410 | */ |
| 411 | static NodeID add_l2_normalize_node(Graph &g, NodeParams params, NodeIdxPair input, int axis, float epsilon); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 412 | /** Adds a normalization layer node to the graph |
| 413 | * |
| 414 | * @param[in] g Graph to add the node to |
| 415 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 416 | * @param[in] input Input to the normalization layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 417 | * @param[in] norm_info Normalization layer information |
| 418 | * |
| 419 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 420 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 421 | static NodeID |
| 422 | add_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, NormalizationLayerInfo norm_info); |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 423 | /** Adds a normalize planar YUV layer node to the graph |
| 424 | * |
| 425 | * @param[in] g Graph to add the node to |
| 426 | * @param[in] params Common node parameters |
| 427 | * @param[in] input Input to the normalize planar YUV layer node as a NodeID-Index pair |
| 428 | * @param[in] mean_accessor Const Node ID that contains the mean values |
| 429 | * @param[in] std_accessor Const Node ID that contains the variance values |
| 430 | * |
| 431 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 432 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 433 | static NodeID add_normalize_planar_yuv_node(Graph &g, |
| 434 | NodeParams params, |
| 435 | NodeIdxPair input, |
| 436 | ITensorAccessorUPtr mean_accessor = nullptr, |
| 437 | ITensorAccessorUPtr std_accessor = nullptr); |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 438 | /** Adds a pad layer node to the graph |
| 439 | * |
Georgios Pinitas | 102b0ce | 2020-02-13 17:59:09 +0000 | [diff] [blame] | 440 | * @param[in] g Graph to add the node to |
| 441 | * @param[in] params Common node parameters |
| 442 | * @param[in] input Input to the reshape layer node as a NodeID-Index pair |
| 443 | * @param[in] paddings The padding for each spatial dimension of the input tensor. The pair padding[i] |
| 444 | * specifies the front and the end padding in the i-th dimension. |
| 445 | * @param[in] pad_value Padding value to be used. Defaults to 0 |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 446 | * |
| 447 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 448 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 449 | static NodeID add_pad_node(Graph &g, |
| 450 | NodeParams params, |
| 451 | NodeIdxPair input, |
| 452 | const PaddingList &paddings, |
| 453 | PixelValue pad_value = PixelValue()); |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 454 | /** Adds a permute layer node to the graph |
| 455 | * |
| 456 | * @param[in] g Graph to add the node to |
| 457 | * @param[in] params Common node parameters |
| 458 | * @param[in] input Input to the reshape layer node as a NodeID-Index pair |
| 459 | * @param[in] perm Permutation vector |
| 460 | * @param[in] layout (Optional) Data layout to assign to permuted tensor. |
| 461 | * If UNKNOWN then the input's layout will be used. |
| 462 | * |
| 463 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 464 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 465 | static NodeID add_permute_node(Graph &g, |
| 466 | NodeParams params, |
| 467 | NodeIdxPair input, |
| 468 | PermutationVector perm, |
| 469 | DataLayout layout = DataLayout::UNKNOWN); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 470 | /** Adds a pooling layer node to the graph |
| 471 | * |
| 472 | * @param[in] g Graph to add the node to |
| 473 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 474 | * @param[in] input Input to the pooling layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 475 | * @param[in] pool_info Pooling layer information |
| 476 | * |
| 477 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 478 | */ |
| 479 | static NodeID add_pooling_node(Graph &g, NodeParams params, NodeIdxPair input, PoolingLayerInfo pool_info); |
Georgios Pinitas | f8c4749 | 2020-02-04 17:39:59 +0000 | [diff] [blame] | 480 | /** Adds a prelu layer node to the graph |
| 481 | * |
| 482 | * @param[in] g Graph to add the node to |
| 483 | * @param[in] params Common node parameters |
| 484 | * @param[in] input Input to the PRelu node as a NodeID-Index pair |
| 485 | * @param[in] alpha Alpha input to the PRelu node as a NodeID-Index pair |
| 486 | * |
| 487 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 488 | */ |
| 489 | static NodeID add_prelu_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair alpha); |
Giorgio Arena | 6e9d0e0 | 2020-01-03 15:02:04 +0000 | [diff] [blame] | 490 | /** Adds a print layer node to the graph |
| 491 | * |
| 492 | * @param[in] g Graph to add the node to |
| 493 | * @param[in] params Common node parameters |
| 494 | * @param[in] input Input to the print layer node as a NodeID-Index pair |
| 495 | * @param[in] stream Output stream. |
| 496 | * @param[in] format_info (Optional) Format info. |
| 497 | * @param[in] transform (Optional) Transformation function to be applied to the input tensor before printing. |
| 498 | * |
| 499 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 500 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 501 | static NodeID add_print_node(Graph &g, |
| 502 | NodeParams params, |
| 503 | NodeIdxPair input, |
| 504 | std::ostream &stream, |
| 505 | const IOFormatInfo &format_info = IOFormatInfo(), |
| 506 | const std::function<ITensor *(ITensor *)> transform = nullptr); |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 507 | /** Adds a priorbox layer node to the graph |
| 508 | * |
| 509 | * @param[in] g Graph to add the node to |
| 510 | * @param[in] params Common node parameters |
| 511 | * @param[in] input0 First input to the priorbox layer node as a NodeID-Index pair |
| 512 | * @param[in] input1 Second input to the priorbox layer node as a NodeID-Index pair |
| 513 | * @param[in] prior_info PriorBox parameters |
| 514 | * |
| 515 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 516 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 517 | static NodeID add_priorbox_node( |
| 518 | Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, const PriorBoxLayerInfo &prior_info); |
Isabella Gottardi | 3db1ba9 | 2019-05-17 12:35:20 +0100 | [diff] [blame] | 519 | /** Adds a quantization layer node to the graph |
| 520 | * |
| 521 | * @param[in] g Graph to add the node to |
| 522 | * @param[in] params Common node parameters |
| 523 | * @param[in] input Input to the quantization layer node as a NodeID-Index pair |
| 524 | * @param[in] out_quant_info Output quantization info |
| 525 | * |
| 526 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 527 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 528 | static NodeID |
| 529 | add_quantization_node(Graph &g, NodeParams params, NodeIdxPair input, const QuantizationInfo &out_quant_info); |
thecha01 | d64444b | 2020-09-07 14:50:21 +0100 | [diff] [blame] | 530 | /** Adds a reduction sum layer node to the graph |
| 531 | * |
| 532 | * @param[in] g Graph to add the node to |
| 533 | * @param[in] params Common node parameters |
| 534 | * @param[in] input Input to the reorg layer node as a NodeID-Index pair |
| 535 | * @param[in] op Reduction operation |
| 536 | * @param[in] axis Reduction axis |
| 537 | * @param[in] keep_dims (Optional) Whether to keep the reduced dimension after the operation. Defaults to true. |
| 538 | * |
| 539 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 540 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 541 | static NodeID add_reduction_operation_node( |
| 542 | Graph &g, NodeParams params, NodeIdxPair input, ReductionOperation op, int axis, bool keep_dims = true); |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 543 | /** Adds a reorg layer node to the graph |
| 544 | * |
| 545 | * @param[in] g Graph to add the node to |
| 546 | * @param[in] params Common node parameters |
| 547 | * @param[in] input Input to the reorg layer node as a NodeID-Index pair |
| 548 | * @param[in] stride Stride value to use for reorganizing the values in the output tensor. |
| 549 | * |
| 550 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 551 | */ |
| 552 | static NodeID add_reorg_node(Graph &g, NodeParams params, NodeIdxPair input, int stride); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 553 | /** Adds a reshape layer node to the graph |
| 554 | * |
| 555 | * @param[in] g Graph to add the node to |
| 556 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 557 | * @param[in] input Input to the reshape layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 558 | * @param[in] shape Output reshaped shape |
| 559 | * |
| 560 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 561 | */ |
| 562 | static NodeID add_reshape_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 563 | /** Adds a resize layer node to the graph |
| 564 | * |
| 565 | * @param[in] g Graph to add the node to |
| 566 | * @param[in] params Common node parameters |
| 567 | * @param[in] input Input to the reshape layer node as a NodeID-Index pair |
| 568 | * @param[in] policy Interpolation policy |
| 569 | * @param[in] width_scale Width scaling factor |
| 570 | * @param[in] height_scale Height scaling factor |
| 571 | * |
| 572 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 573 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 574 | static NodeID add_resize_node(Graph &g, |
| 575 | NodeParams params, |
| 576 | NodeIdxPair input, |
| 577 | InterpolationPolicy policy, |
| 578 | float width_scale, |
| 579 | float height_scale); |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 580 | /** Adds a ROI align layer node to the graph |
| 581 | * |
| 582 | * @param[in] g Graph to add the node to |
| 583 | * @param[in] params Common node parameters |
| 584 | * @param[in] input Input to the reshape layer node as a NodeID-Index pair |
Manuel Bottini | cc5171b | 2019-01-09 17:04:39 +0000 | [diff] [blame] | 585 | * @param[in] rois Input containing the ROIs. |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 586 | * @param[in] pool_info Contains pooling operation information described in @ref ROIPoolingLayerInfo. |
| 587 | * |
| 588 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 589 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 590 | static NodeID |
| 591 | add_roi_align_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair rois, ROIPoolingLayerInfo pool_info); |
Isabella Gottardi | 88d5b22 | 2018-04-06 12:24:55 +0100 | [diff] [blame] | 592 | /** Adds a scale layer node to the graph |
| 593 | * This layer computes a product of the input with a scale (read from mul_accessor) and it applies an offset (read from add_accessor). |
| 594 | * output = input * mul_w + add_w |
| 595 | * |
| 596 | * @param[in] g Graph to add the layer to |
| 597 | * @param[in] params Common node parameters |
| 598 | * @param[in] input Input to the fully connected layer node as a NodeID-Index pair |
| 599 | * @param[in] mul_accessor (Optional) Accessor of the mul node data |
| 600 | * @param[in] add_accessor (Optional) Accessor of the add node data |
| 601 | * |
| 602 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 603 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 604 | static NodeID add_scale_layer(Graph &g, |
| 605 | const NodeParams ¶ms, |
| 606 | NodeIdxPair input, |
| 607 | ITensorAccessorUPtr mul_accessor = nullptr, |
| 608 | ITensorAccessorUPtr add_accessor = nullptr); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 609 | /** Adds a softmax node to the graph |
| 610 | * |
| 611 | * @param[in] g Graph to add the node to |
| 612 | * @param[in] params Common node parameters |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 613 | * @param[in] input Input to the softmax layer node as a NodeID-Index pair |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 614 | * @param[in] beta Beta parameter |
| 615 | * |
| 616 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 617 | */ |
| 618 | static NodeID add_softmax_node(Graph &g, NodeParams params, NodeIdxPair input, float beta = 1.f); |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 619 | /** Adds a slice node to the graph |
| 620 | * |
| 621 | * @param[in] g Graph to add the node to |
| 622 | * @param[in] params Common node parameters |
| 623 | * @param[in] input Input to the slice layer node as a NodeID-Index pair |
| 624 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 625 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 626 | * |
| 627 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 628 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 629 | static NodeID |
| 630 | add_slice_node(Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends); |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 631 | /** Adds a split node to the graph |
| 632 | * |
| 633 | * @param[in] g Graph to add the node to |
| 634 | * @param[in] params Common node parameters |
| 635 | * @param[in] input Input to the split layer node as a NodeID-Index pair |
| 636 | * @param[in] num_splits Number of different splits |
| 637 | * @param[in] axis (Optional) Split axis. Defaults to 0 |
| 638 | * |
| 639 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 640 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 641 | static NodeID |
| 642 | add_split_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis = 0); |
Michele Di Giorgio | ec69975 | 2019-03-22 15:25:32 +0000 | [diff] [blame] | 643 | /** Adds a stack layer node to the graph |
| 644 | * |
| 645 | * @param[in] g Graph to add the node to |
| 646 | * @param[in] params Common node parameters |
| 647 | * @param[in] inputs Inputs to the reorg layer node as a NodeID-Index pair |
| 648 | * @param[in] axis Axis along which the input tensors have to be packed |
| 649 | * |
| 650 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 651 | */ |
| 652 | static NodeID add_stack_node(Graph &g, NodeParams params, const std::vector<NodeIdxPair> &inputs, int axis); |
thecha01 | 2bfadd9 | 2020-08-12 17:25:51 +0100 | [diff] [blame] | 653 | /** Adds a strided slice node to the graph |
| 654 | * |
| 655 | * @param[in] g Graph to add the node to |
| 656 | * @param[in] params Common node parameters |
| 657 | * @param[in] input Input to the strided slice layer node as a NodeID-Index pair |
| 658 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 659 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 660 | * @param[in] strides The strides of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 661 | * @param[in] info Contains masks for the starts, ends and strides |
| 662 | * |
| 663 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 664 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 665 | static NodeID add_strided_slice_node(Graph &g, |
| 666 | NodeParams params, |
| 667 | NodeIdxPair input, |
| 668 | Coordinates &starts, |
| 669 | Coordinates &ends, |
| 670 | BiStrides &strides, |
| 671 | StridedSliceLayerInfo info); |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 672 | /** Adds a yolo layer to the graph |
| 673 | * |
Georgios Pinitas | 0b1c2db | 2020-12-04 15:51:34 +0000 | [diff] [blame] | 674 | * @param[in] g Graph to add the node to |
| 675 | * @param[in] params Common node parameters |
| 676 | * @param[in] input Input to the yolo layer node as a NodeID-Index pair |
| 677 | * @param[in] act_info Activation layer parameters |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 678 | * |
| 679 | * @return Node ID of the created node, EmptyNodeID in case of error |
| 680 | */ |
Georgios Pinitas | 0b1c2db | 2020-12-04 15:51:34 +0000 | [diff] [blame] | 681 | static NodeID add_yolo_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 682 | }; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 683 | } // namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 684 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 685 | #endif /* ARM_COMPUTE_GRAPH_GRAPH_BUILDER_H */ |