Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
Giuseppe Rossini | bb365de | 2019-02-15 10:24:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 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 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 24 | #include "arm_compute/graph/GraphBuilder.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 25 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 26 | #include "arm_compute/graph/Graph.h" |
| 27 | #include "arm_compute/graph/Utils.h" |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 28 | #include "arm_compute/graph/algorithms/TopologicalSort.h" |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 29 | #include "arm_compute/graph/nodes/Nodes.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 30 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 31 | #include "support/ToolchainSupport.h" |
| 32 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 33 | #define CHECK_NODEIDX_PAIR(pair, g) \ |
| 34 | ARM_COMPUTE_ERROR_ON(((pair).node_id >= (g).nodes().size()) || ((g).node((pair).node_id) == nullptr) || ((pair).index >= (g).node((pair).node_id)->num_outputs())); |
| 35 | |
| 36 | namespace arm_compute |
| 37 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 38 | namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 39 | { |
| 40 | namespace |
| 41 | { |
| 42 | Status set_node_params(Graph &g, NodeID nid, NodeParams ¶ms) |
| 43 | { |
| 44 | INode *node = g.node(nid); |
| 45 | ARM_COMPUTE_RETURN_ERROR_ON(!node); |
| 46 | |
| 47 | node->set_common_node_parameters(params); |
| 48 | |
| 49 | return Status{}; |
| 50 | } |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 51 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 52 | Status set_accessor_on_node(Graph &g, NodeID nid, bool is_output, size_t idx, ITensorAccessorUPtr accessor) |
| 53 | { |
| 54 | INode *node = g.node(nid); |
| 55 | ARM_COMPUTE_RETURN_ERROR_ON(!node); |
| 56 | |
| 57 | Tensor *tensor = is_output ? node->output(idx) : node->input(idx); |
| 58 | ARM_COMPUTE_RETURN_ERROR_ON(!tensor); |
| 59 | |
| 60 | tensor->set_accessor(std::move(accessor)); |
| 61 | |
| 62 | return Status{}; |
| 63 | } |
| 64 | |
| 65 | NodeID add_const_node_with_name(Graph &g, NodeParams params, const std::string &name, TensorDescriptor desc, ITensorAccessorUPtr accessor) |
| 66 | { |
| 67 | params.name = params.name.empty() ? "" : params.name + name; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 68 | auto nid = GraphBuilder::add_const_node(g, params, std::move(desc), std::move(accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 69 | set_node_params(g, nid, params); |
| 70 | return nid; |
| 71 | } |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 72 | |
| 73 | template <typename NT, typename... Args> |
| 74 | NodeID create_simple_single_input_output_node(Graph &g, NodeParams ¶ms, NodeIdxPair input, Args &&... args) |
| 75 | { |
| 76 | CHECK_NODEIDX_PAIR(input, g); |
| 77 | |
| 78 | NodeID nid = g.add_node<NT>(std::forward<Args>(args)...); |
| 79 | g.add_connection(input.node_id, input.index, nid, 0); |
| 80 | set_node_params(g, nid, params); |
| 81 | |
| 82 | return nid; |
| 83 | } |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 84 | } // namespace |
| 85 | |
| 86 | NodeID GraphBuilder::add_const_node(Graph &g, NodeParams params, TensorDescriptor desc, ITensorAccessorUPtr accessor) |
| 87 | { |
| 88 | auto nid = g.add_node<ConstNode>(desc); |
| 89 | set_node_params(g, nid, params); |
| 90 | set_accessor_on_node(g, nid, true, 0, std::move(accessor)); |
| 91 | return nid; |
| 92 | } |
| 93 | |
| 94 | NodeID GraphBuilder::add_input_node(Graph &g, NodeParams params, TensorDescriptor desc, ITensorAccessorUPtr accessor) |
| 95 | { |
| 96 | auto nid = g.add_node<InputNode>(desc); |
| 97 | set_node_params(g, nid, params); |
| 98 | set_accessor_on_node(g, nid, true, 0, std::move(accessor)); |
| 99 | return nid; |
| 100 | } |
| 101 | |
| 102 | NodeID GraphBuilder::add_output_node(Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr accessor) |
| 103 | { |
| 104 | CHECK_NODEIDX_PAIR(input, g); |
| 105 | |
| 106 | NodeID nid = g.add_node<OutputNode>(); |
| 107 | g.add_connection(input.node_id, input.index, nid, 0); |
| 108 | set_node_params(g, nid, params); |
| 109 | set_accessor_on_node(g, nid, false, 0, std::move(accessor)); |
| 110 | |
| 111 | return nid; |
| 112 | } |
| 113 | |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 114 | NodeID GraphBuilder::add_activation_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info, |
| 115 | const QuantizationInfo out_quant_info) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 116 | { |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 117 | return create_simple_single_input_output_node<ActivationLayerNode>(g, params, input, act_info, out_quant_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | NodeID GraphBuilder::add_batch_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, float epsilon, |
| 121 | ITensorAccessorUPtr mean_accessor, ITensorAccessorUPtr var_accessor, |
| 122 | ITensorAccessorUPtr beta_accessor, ITensorAccessorUPtr gamma_accessor) |
| 123 | { |
| 124 | CHECK_NODEIDX_PAIR(input, g); |
| 125 | |
| 126 | bool has_beta = (beta_accessor != nullptr); |
| 127 | bool has_gamma = (gamma_accessor != nullptr); |
| 128 | |
| 129 | // Get input tensor descriptor |
| 130 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 131 | |
| 132 | // Calculate Common Descriptor |
| 133 | TensorDescriptor common_desc = input_tensor_desc; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 134 | common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 135 | |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 136 | // Create mean and var nodes |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 137 | auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor)); |
| 138 | auto var_nid = add_const_node_with_name(g, params, "Variance", common_desc, std::move(var_accessor)); |
| 139 | |
| 140 | // Create beta node |
| 141 | NodeID beta_nid = EmptyNodeID; |
| 142 | if(has_beta) |
| 143 | { |
| 144 | beta_nid = add_const_node_with_name(g, params, "Beta", common_desc, std::move(beta_accessor)); |
| 145 | } |
| 146 | |
| 147 | // Create gamma node |
| 148 | NodeID gamma_nid = EmptyNodeID; |
| 149 | if(has_gamma) |
| 150 | { |
| 151 | gamma_nid = add_const_node_with_name(g, params, "Gamma", common_desc, std::move(gamma_accessor)); |
| 152 | } |
| 153 | |
| 154 | // Create batch normalization node and add connections |
| 155 | NodeID batch_norm_nid = g.add_node<BatchNormalizationLayerNode>(epsilon); |
| 156 | g.add_connection(input.node_id, input.index, batch_norm_nid, 0); |
| 157 | g.add_connection(mean_nid, 0, batch_norm_nid, 1); |
| 158 | g.add_connection(var_nid, 0, batch_norm_nid, 2); |
| 159 | if(has_beta) |
| 160 | { |
| 161 | g.add_connection(beta_nid, 0, batch_norm_nid, 3); |
| 162 | } |
| 163 | if(has_gamma) |
| 164 | { |
| 165 | g.add_connection(gamma_nid, 0, batch_norm_nid, 4); |
| 166 | } |
| 167 | set_node_params(g, batch_norm_nid, params); |
| 168 | |
| 169 | return batch_norm_nid; |
| 170 | } |
| 171 | |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 172 | NodeID GraphBuilder::add_bounding_box_transform_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair deltas, BoundingBoxTransformInfo info) |
| 173 | { |
| 174 | CHECK_NODEIDX_PAIR(input, g); |
| 175 | CHECK_NODEIDX_PAIR(deltas, g); |
| 176 | |
| 177 | NodeID nid = g.add_node<BoundingBoxTransformLayerNode>(info); |
| 178 | |
| 179 | g.add_connection(input.node_id, input.index, nid, 0); |
| 180 | g.add_connection(deltas.node_id, deltas.index, nid, 1); |
| 181 | |
| 182 | set_node_params(g, nid, params); |
| 183 | return nid; |
| 184 | } |
| 185 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 186 | NodeID GraphBuilder::add_channel_shuffle_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_groups) |
| 187 | { |
| 188 | return create_simple_single_input_output_node<ChannelShuffleLayerNode>(g, params, input, num_groups); |
| 189 | } |
| 190 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 191 | NodeID GraphBuilder::add_convolution_node(Graph &g, NodeParams params, NodeIdxPair input, |
| 192 | Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo conv_info, |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 193 | unsigned int num_groups, ConvolutionMethod method, FastMathHint fast_math_hint, |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 194 | ITensorAccessorUPtr weights_accessor, ITensorAccessorUPtr bias_accessor, |
| 195 | const QuantizationInfo weights_quant_info, |
| 196 | const QuantizationInfo out_quant_info) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 197 | { |
| 198 | CHECK_NODEIDX_PAIR(input, g); |
| 199 | ARM_COMPUTE_ERROR_ON(depth == 0); |
| 200 | ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0)); |
| 201 | |
| 202 | bool has_bias = (bias_accessor != nullptr); |
| 203 | |
| 204 | // Get input tensor descriptor |
| 205 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 206 | |
| 207 | // Create weights node |
| 208 | TensorDescriptor w_desc = input_tensor_desc; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 209 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::WIDTH), kernel_spatial_extend.width); |
| 210 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height); |
| 211 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::CHANNEL), |
| 212 | get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) / num_groups); |
| 213 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::BATCHES), depth); |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 214 | if(!weights_quant_info.empty()) |
| 215 | { |
| 216 | w_desc.quant_info = weights_quant_info; |
| 217 | } |
| 218 | |
| 219 | NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 220 | |
| 221 | // Create bias nodes |
| 222 | NodeID b_nid = EmptyNodeID; |
| 223 | if(has_bias) |
| 224 | { |
| 225 | TensorDescriptor b_desc = input_tensor_desc; |
| 226 | b_desc.shape = TensorShape(depth); |
Michele Di Giorgio | 3a3b431 | 2018-07-06 12:34:19 +0100 | [diff] [blame] | 227 | if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type)) |
| 228 | { |
| 229 | b_desc.data_type = DataType::S32; |
| 230 | } |
| 231 | b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 234 | // Create convolution node and connect |
| 235 | NodeID conv_nid = g.add_node<ConvolutionLayerNode>(conv_info, num_groups, method, fast_math_hint, out_quant_info); |
| 236 | g.add_connection(input.node_id, input.index, conv_nid, 0); |
| 237 | g.add_connection(w_nid, 0, conv_nid, 1); |
| 238 | if(has_bias) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 239 | { |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 240 | g.add_connection(b_nid, 0, conv_nid, 2); |
| 241 | } |
| 242 | set_node_params(g, conv_nid, params); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 243 | |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 244 | return conv_nid; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 247 | NodeID GraphBuilder::add_deconvolution_node(Graph &g, NodeParams params, NodeIdxPair input, |
| 248 | Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo deconv_info, |
| 249 | Size2D inner_border, ITensorAccessorUPtr weights_accessor, |
| 250 | ITensorAccessorUPtr bias_accessor) |
| 251 | { |
| 252 | CHECK_NODEIDX_PAIR(input, g); |
| 253 | ARM_COMPUTE_ERROR_ON(depth == 0); |
| 254 | ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0)); |
| 255 | |
| 256 | bool has_bias = (bias_accessor != nullptr); |
| 257 | |
| 258 | // Get input tensor descriptor |
| 259 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 260 | |
| 261 | // Create weights node |
| 262 | TensorDescriptor w_desc = input_tensor_desc; |
| 263 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::WIDTH), kernel_spatial_extend.width); |
| 264 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height); |
| 265 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::CHANNEL), |
| 266 | get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL)); |
| 267 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::BATCHES), depth); |
| 268 | |
| 269 | NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor)); |
| 270 | |
| 271 | // Create bias nodes |
| 272 | NodeID b_nid = EmptyNodeID; |
| 273 | if(has_bias) |
| 274 | { |
| 275 | TensorDescriptor b_desc = input_tensor_desc; |
| 276 | b_desc.shape = TensorShape(depth); |
Michele Di Giorgio | 3a3b431 | 2018-07-06 12:34:19 +0100 | [diff] [blame] | 277 | if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type)) |
| 278 | { |
| 279 | b_desc.data_type = DataType::S32; |
| 280 | } |
| 281 | b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor)); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | // Create convolution node and connect |
| 285 | NodeID deconv_nid = g.add_node<DeconvolutionLayerNode>(deconv_info, inner_border); |
| 286 | g.add_connection(input.node_id, input.index, deconv_nid, 0); |
| 287 | g.add_connection(w_nid, 0, deconv_nid, 1); |
| 288 | if(has_bias) |
| 289 | { |
| 290 | g.add_connection(b_nid, 0, deconv_nid, 2); |
| 291 | } |
| 292 | set_node_params(g, deconv_nid, params); |
| 293 | |
| 294 | return deconv_nid; |
| 295 | } |
| 296 | |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 297 | NodeID GraphBuilder::add_concatenate_node(Graph &g, NodeParams params, std::vector<NodeIdxPair> inputs, descriptors::ConcatLayerDescriptor concat_descriptor) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 298 | { |
| 299 | ARM_COMPUTE_ERROR_ON(inputs.size() == 0); |
| 300 | |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 301 | NodeID nid = g.add_node<ConcatenateLayerNode>(inputs.size(), concat_descriptor); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 302 | |
| 303 | unsigned int i = 0; |
| 304 | for(const auto &input : inputs) |
| 305 | { |
| 306 | CHECK_NODEIDX_PAIR(input, g); |
| 307 | g.add_connection(input.node_id, input.index, nid, i++); |
| 308 | } |
| 309 | set_node_params(g, nid, params); |
| 310 | |
| 311 | return nid; |
| 312 | } |
| 313 | |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 314 | NodeID GraphBuilder::add_depthwise_convolution_node(Graph &g, NodeParams params, NodeIdxPair input, Size2D kernel_spatial_extend, |
| 315 | PadStrideInfo conv_info, int depth_multiplier, DepthwiseConvolutionMethod method, |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 316 | ITensorAccessorUPtr weights_accessor, ITensorAccessorUPtr bias_accessor, const QuantizationInfo quant_info, const QuantizationInfo out_quant_info) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 317 | { |
| 318 | CHECK_NODEIDX_PAIR(input, g); |
| 319 | ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0)); |
| 320 | |
| 321 | bool has_bias = (bias_accessor != nullptr); |
| 322 | |
| 323 | // Get input tensor descriptor |
| 324 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 325 | |
| 326 | // Create weights node |
| 327 | TensorDescriptor w_desc = input_tensor_desc; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 328 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::WIDTH), kernel_spatial_extend.width); |
| 329 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height); |
| 330 | w_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::CHANNEL), |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 331 | get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier); |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 332 | if(!quant_info.empty()) |
| 333 | { |
| 334 | w_desc.quant_info = quant_info; |
| 335 | } |
| 336 | |
| 337 | NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 338 | |
| 339 | // Create bias nodes |
| 340 | NodeID b_nid = EmptyNodeID; |
| 341 | if(has_bias) |
| 342 | { |
| 343 | TensorDescriptor b_desc = input_tensor_desc; |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 344 | b_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier); |
Giorgio Arena | 2aa0ec4 | 2018-08-29 14:28:38 +0100 | [diff] [blame] | 345 | |
| 346 | if(is_data_type_quantized_asymmetric(b_desc.data_type)) |
| 347 | { |
| 348 | b_desc.data_type = DataType::S32; |
| 349 | } |
| 350 | |
| 351 | b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | // Create convolution node and connect |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame^] | 355 | NodeID conv_nid = g.add_node<DepthwiseConvolutionLayerNode>(conv_info, depth_multiplier, method, out_quant_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 356 | g.add_connection(input.node_id, input.index, conv_nid, 0); |
| 357 | g.add_connection(w_nid, 0, conv_nid, 1); |
| 358 | if(has_bias) |
| 359 | { |
| 360 | g.add_connection(b_nid, 0, conv_nid, 2); |
| 361 | } |
| 362 | set_node_params(g, conv_nid, params); |
| 363 | |
| 364 | return conv_nid; |
| 365 | } |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 366 | NodeID GraphBuilder::add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, DetectionOutputLayerInfo detect_info) |
| 367 | { |
| 368 | CHECK_NODEIDX_PAIR(input_loc, g); |
| 369 | CHECK_NODEIDX_PAIR(input_conf, g); |
| 370 | CHECK_NODEIDX_PAIR(input_priorbox, g); |
| 371 | |
| 372 | // Create detection_output node and connect |
| 373 | NodeID detect_nid = g.add_node<DetectionOutputLayerNode>(detect_info); |
| 374 | g.add_connection(input_loc.node_id, input_loc.index, detect_nid, 0); |
| 375 | g.add_connection(input_conf.node_id, input_conf.index, detect_nid, 1); |
| 376 | g.add_connection(input_priorbox.node_id, input_priorbox.index, detect_nid, 2); |
| 377 | |
| 378 | set_node_params(g, detect_nid, params); |
| 379 | |
| 380 | return detect_nid; |
| 381 | } |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 382 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 383 | NodeID GraphBuilder::add_dummy_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape) |
| 384 | { |
Georgios Pinitas | b7a2023 | 2018-07-02 16:12:54 +0100 | [diff] [blame] | 385 | return create_simple_single_input_output_node<DummyNode>(g, params, input, shape); |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 386 | } |
| 387 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 388 | NodeID GraphBuilder::add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation) |
| 389 | { |
| 390 | CHECK_NODEIDX_PAIR(input0, g); |
| 391 | CHECK_NODEIDX_PAIR(input1, g); |
| 392 | |
| 393 | NodeID nid = g.add_node<EltwiseLayerNode>(operation); |
| 394 | |
| 395 | g.add_connection(input0.node_id, input0.index, nid, 0); |
| 396 | g.add_connection(input1.node_id, input1.index, nid, 1); |
| 397 | |
| 398 | set_node_params(g, nid, params); |
| 399 | |
| 400 | return nid; |
| 401 | } |
| 402 | |
| 403 | NodeID GraphBuilder::add_flatten_node(Graph &g, NodeParams params, NodeIdxPair input) |
| 404 | { |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 405 | return create_simple_single_input_output_node<FlattenLayerNode>(g, params, input); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | NodeID GraphBuilder::add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs, |
Michele Di Giorgio | a42f55f | 2019-03-08 14:52:17 +0000 | [diff] [blame] | 409 | NodeID weights_nid, NodeID bias_nid, |
| 410 | const FullyConnectedLayerInfo fc_info, const QuantizationInfo out_quant_info) |
| 411 | { |
| 412 | CHECK_NODEIDX_PAIR(input, g); |
| 413 | ARM_COMPUTE_ERROR_ON(num_outputs == 0); |
| 414 | ARM_COMPUTE_ERROR_ON(weights_nid == EmptyNodeID); |
| 415 | |
| 416 | const bool has_bias = (bias_nid != EmptyNodeID); |
| 417 | |
| 418 | // Get input tensor descriptor |
| 419 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 420 | |
| 421 | // Create fully connected node and connect |
| 422 | NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info); |
| 423 | g.add_connection(input.node_id, input.index, fc_nid, 0); |
| 424 | g.add_connection(weights_nid, 0, fc_nid, 1); |
| 425 | if(has_bias) |
| 426 | { |
| 427 | g.add_connection(bias_nid, 0, fc_nid, 2); |
| 428 | } |
| 429 | |
| 430 | set_node_params(g, fc_nid, params); |
| 431 | |
| 432 | return fc_nid; |
| 433 | } |
| 434 | |
| 435 | NodeID GraphBuilder::add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs, |
Georgios Pinitas | 2f1366a | 2018-07-31 16:33:06 +0100 | [diff] [blame] | 436 | ITensorAccessorUPtr weights_accessor, ITensorAccessorUPtr bias_accessor, |
Georgios Pinitas | c55cef1 | 2018-08-01 15:24:18 +0100 | [diff] [blame] | 437 | const FullyConnectedLayerInfo fc_info, |
Georgios Pinitas | 2f1366a | 2018-07-31 16:33:06 +0100 | [diff] [blame] | 438 | const QuantizationInfo weights_quant_info, const QuantizationInfo out_quant_info) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 439 | { |
| 440 | CHECK_NODEIDX_PAIR(input, g); |
| 441 | ARM_COMPUTE_ERROR_ON(num_outputs == 0); |
| 442 | |
| 443 | bool has_bias = (bias_accessor != nullptr); |
| 444 | |
| 445 | // Get input tensor descriptor |
| 446 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 447 | |
| 448 | // Create weights node |
Georgios Pinitas | 195b0ba | 2018-08-02 17:18:51 +0100 | [diff] [blame] | 449 | TensorDescriptor w_desc = FullyConnectedLayerNode::compute_weights_descriptor(input_tensor_desc, num_outputs, fc_info, weights_quant_info); |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 450 | NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 451 | |
| 452 | // Create bias nodes |
| 453 | NodeID b_nid = EmptyNodeID; |
| 454 | if(has_bias) |
| 455 | { |
| 456 | TensorDescriptor b_desc = input_tensor_desc; |
| 457 | b_desc.shape = TensorShape(num_outputs); |
Michele Di Giorgio | 3a3b431 | 2018-07-06 12:34:19 +0100 | [diff] [blame] | 458 | if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type)) |
| 459 | { |
| 460 | b_desc.data_type = DataType::S32; |
| 461 | } |
| 462 | b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor)); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Georgios Pinitas | 7d66a8e | 2018-07-17 12:28:42 +0100 | [diff] [blame] | 465 | // Create fully connected node and connect |
Georgios Pinitas | 2f1366a | 2018-07-31 16:33:06 +0100 | [diff] [blame] | 466 | NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 467 | g.add_connection(input.node_id, input.index, fc_nid, 0); |
| 468 | g.add_connection(w_nid, 0, fc_nid, 1); |
| 469 | if(has_bias) |
| 470 | { |
| 471 | g.add_connection(b_nid, 0, fc_nid, 2); |
| 472 | } |
| 473 | |
| 474 | set_node_params(g, fc_nid, params); |
| 475 | |
| 476 | return fc_nid; |
| 477 | } |
| 478 | |
Manuel Bottini | 5209be5 | 2019-02-13 16:34:56 +0000 | [diff] [blame] | 479 | NodeID GraphBuilder::add_generate_proposals_node(Graph &g, NodeParams params, NodeIdxPair scores, NodeIdxPair deltas, NodeIdxPair anchors, GenerateProposalsInfo info) |
| 480 | { |
| 481 | CHECK_NODEIDX_PAIR(scores, g); |
| 482 | CHECK_NODEIDX_PAIR(deltas, g); |
| 483 | CHECK_NODEIDX_PAIR(anchors, g); |
| 484 | |
| 485 | NodeID nid = g.add_node<GenerateProposalsLayerNode>(info); |
| 486 | |
| 487 | g.add_connection(scores.node_id, scores.index, nid, 0); |
| 488 | g.add_connection(deltas.node_id, deltas.index, nid, 1); |
| 489 | g.add_connection(anchors.node_id, anchors.index, nid, 2); |
| 490 | |
| 491 | set_node_params(g, nid, params); |
| 492 | return nid; |
| 493 | } |
| 494 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 495 | NodeID GraphBuilder::add_normalization_node(Graph &g, NodeParams params, NodeIdxPair input, NormalizationLayerInfo norm_info) |
| 496 | { |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 497 | return create_simple_single_input_output_node<NormalizationLayerNode>(g, params, input, norm_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 498 | } |
| 499 | |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 500 | NodeID GraphBuilder::add_normalize_planar_yuv_node(Graph &g, NodeParams params, NodeIdxPair input, |
| 501 | ITensorAccessorUPtr mean_accessor, ITensorAccessorUPtr std_accessor) |
| 502 | { |
| 503 | CHECK_NODEIDX_PAIR(input, g); |
| 504 | |
| 505 | // Get input tensor descriptor |
| 506 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 507 | |
| 508 | // Calculate Common Descriptor |
| 509 | TensorDescriptor common_desc = input_tensor_desc; |
| 510 | common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL)); |
| 511 | |
| 512 | // Create mean and std nodes |
| 513 | auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor)); |
| 514 | auto std_nid = add_const_node_with_name(g, params, "Std", common_desc, std::move(std_accessor)); |
| 515 | |
| 516 | // Create normalize planar YUV node and add connections |
| 517 | NodeID norm_planar_yuv_nid = g.add_node<NormalizePlanarYUVLayerNode>(); |
| 518 | g.add_connection(input.node_id, input.index, norm_planar_yuv_nid, 0); |
| 519 | g.add_connection(mean_nid, 0, norm_planar_yuv_nid, 1); |
| 520 | g.add_connection(std_nid, 0, norm_planar_yuv_nid, 2); |
| 521 | set_node_params(g, norm_planar_yuv_nid, params); |
| 522 | |
| 523 | return norm_planar_yuv_nid; |
| 524 | } |
| 525 | |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 526 | NodeID GraphBuilder::add_pad_node(Graph &g, NodeParams params, NodeIdxPair input, PaddingList padding) |
| 527 | { |
| 528 | return create_simple_single_input_output_node<PadLayerNode>(g, params, input, padding); |
| 529 | } |
| 530 | |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 531 | NodeID GraphBuilder::add_permute_node(Graph &g, NodeParams params, NodeIdxPair input, PermutationVector perm, DataLayout layout) |
| 532 | { |
| 533 | return create_simple_single_input_output_node<PermuteLayerNode>(g, params, input, perm, layout); |
| 534 | } |
| 535 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 536 | NodeID GraphBuilder::add_pooling_node(Graph &g, NodeParams params, NodeIdxPair input, PoolingLayerInfo pool_info) |
| 537 | { |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 538 | return create_simple_single_input_output_node<PoolingLayerNode>(g, params, input, pool_info); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 541 | NodeID GraphBuilder::add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, PriorBoxLayerInfo prior_info) |
| 542 | { |
| 543 | CHECK_NODEIDX_PAIR(input0, g); |
| 544 | CHECK_NODEIDX_PAIR(input1, g); |
| 545 | |
| 546 | // Create priorbox node and connect |
| 547 | NodeID prior_nid = g.add_node<PriorBoxLayerNode>(prior_info); |
| 548 | g.add_connection(input0.node_id, input0.index, prior_nid, 0); |
| 549 | g.add_connection(input1.node_id, input1.index, prior_nid, 1); |
| 550 | |
| 551 | set_node_params(g, prior_nid, params); |
| 552 | |
| 553 | return prior_nid; |
| 554 | } |
| 555 | |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 556 | NodeID GraphBuilder::add_reorg_node(Graph &g, NodeParams params, NodeIdxPair input, int stride) |
| 557 | { |
| 558 | return create_simple_single_input_output_node<ReorgLayerNode>(g, params, input, stride); |
| 559 | } |
| 560 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 561 | NodeID GraphBuilder::add_reshape_node(Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape) |
| 562 | { |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 563 | return create_simple_single_input_output_node<ReshapeLayerNode>(g, params, input, shape); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 564 | } |
| 565 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 566 | NodeID GraphBuilder::add_resize_node(Graph &g, NodeParams params, NodeIdxPair input, InterpolationPolicy policy, |
| 567 | float width_scale, float height_scale) |
| 568 | { |
| 569 | return create_simple_single_input_output_node<ResizeLayerNode>(g, params, input, policy, width_scale, height_scale); |
| 570 | } |
| 571 | |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 572 | NodeID GraphBuilder::add_roi_align_node(Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair rois, ROIPoolingLayerInfo pool_info) |
| 573 | { |
| 574 | CHECK_NODEIDX_PAIR(input, g); |
| 575 | CHECK_NODEIDX_PAIR(rois, g); |
| 576 | |
| 577 | NodeID nid = g.add_node<ROIAlignLayerNode>(pool_info); |
| 578 | |
| 579 | g.add_connection(input.node_id, input.index, nid, 0); |
| 580 | g.add_connection(rois.node_id, rois.index, nid, 1); |
| 581 | |
| 582 | set_node_params(g, nid, params); |
| 583 | return nid; |
| 584 | } |
| 585 | |
Isabella Gottardi | 88d5b22 | 2018-04-06 12:24:55 +0100 | [diff] [blame] | 586 | NodeID GraphBuilder::add_scale_layer(Graph &g, const NodeParams ¶ms, NodeIdxPair input, ITensorAccessorUPtr mul_accessor, ITensorAccessorUPtr add_accessor) |
| 587 | { |
| 588 | CHECK_NODEIDX_PAIR(input, g); |
| 589 | |
| 590 | // Get input tensor descriptor |
| 591 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 592 | |
| 593 | // Create mul node |
| 594 | TensorDescriptor mul_desc = input_tensor_desc; |
| 595 | const size_t C = input_tensor_desc.shape[get_dimension_idx(mul_desc, DataLayoutDimension::CHANNEL)]; |
| 596 | mul_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::WIDTH), 1); |
| 597 | mul_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::HEIGHT), 1); |
| 598 | mul_desc.shape.set(get_dimension_idx(input_tensor_desc, DataLayoutDimension::CHANNEL), C); |
| 599 | NodeID mul_const_nid = add_const_node_with_name(g, params, "Mul", mul_desc, std::move(mul_accessor)); |
| 600 | NodeIdxPair mul_const_nidxp = { mul_const_nid, 0 }; |
| 601 | |
| 602 | // Create add node |
| 603 | TensorDescriptor add_desc = mul_desc; |
| 604 | NodeID add_const_nid = add_const_node_with_name(g, params, "Add", add_desc, std::move(add_accessor)); |
| 605 | NodeIdxPair add_const_nidxp = { add_const_nid, 0 }; |
| 606 | |
| 607 | // Create node and connect |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 608 | NodeID mul_node = GraphBuilder::add_elementwise_node(g, params, input, mul_const_nidxp, EltwiseOperation::Mul); |
Isabella Gottardi | 88d5b22 | 2018-04-06 12:24:55 +0100 | [diff] [blame] | 609 | NodeIdxPair mulnode_nidxp = { mul_node, 0 }; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 610 | NodeID add_node = GraphBuilder::add_elementwise_node(g, params, mulnode_nidxp, add_const_nidxp, EltwiseOperation::Add); |
Isabella Gottardi | 88d5b22 | 2018-04-06 12:24:55 +0100 | [diff] [blame] | 611 | |
| 612 | return add_node; |
| 613 | } |
| 614 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 615 | NodeID GraphBuilder::add_softmax_node(Graph &g, NodeParams params, NodeIdxPair input, float beta) |
| 616 | { |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 617 | return create_simple_single_input_output_node<SoftmaxLayerNode>(g, params, input, beta); |
| 618 | } |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 619 | |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 620 | NodeID GraphBuilder::add_slice_node(Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends) |
| 621 | { |
| 622 | return create_simple_single_input_output_node<SliceLayerNode>(g, params, input, starts, ends); |
| 623 | } |
| 624 | |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 625 | NodeID GraphBuilder::add_split_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis) |
| 626 | { |
| 627 | return create_simple_single_input_output_node<SplitLayerNode>(g, params, input, num_splits, axis); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 628 | } |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 629 | |
Michalis Spyrou | 4e1c3f3 | 2018-09-20 17:14:03 +0100 | [diff] [blame] | 630 | NodeID GraphBuilder::add_upsample_node(Graph &g, NodeParams params, NodeIdxPair input, Size2D info, InterpolationPolicy upsampling_policy) |
| 631 | { |
| 632 | return create_simple_single_input_output_node<UpsampleLayerNode>(g, params, input, info, upsampling_policy); |
| 633 | } |
| 634 | |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 635 | NodeID GraphBuilder::add_yolo_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info, int32_t num_classes) |
| 636 | { |
| 637 | return create_simple_single_input_output_node<YOLOLayerNode>(g, params, input, act_info, num_classes); |
| 638 | } |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 639 | } // namespace graph |
Michele Di Giorgio | 3a3b431 | 2018-07-06 12:34:19 +0100 | [diff] [blame] | 640 | } // namespace arm_compute |