Compute Library
 23.08
GraphBuilder Class Referencefinal

Graph builder class. More...

#include <GraphBuilder.h>

Static Public Member Functions

static NodeID add_const_node (Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor=nullptr)
 Adds a Const node to the graph. More...
 
static NodeID add_input_node (Graph &g, NodeParams params, const TensorDescriptor &desc, ITensorAccessorUPtr accessor=nullptr)
 Adds an input layer node to the graph. More...
 
static NodeID add_output_node (Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr accessor=nullptr)
 Adds an output layer node to the graph. More...
 
static NodeID add_activation_node (Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info, const QuantizationInfo &out_quant_info=QuantizationInfo())
 Adds an activation layer node to the graph. More...
 
static NodeID add_arg_min_max_node (Graph &g, NodeParams params, NodeIdxPair input, ReductionOperation op, unsigned int axis, DataType out_data_type=DataType::UNKNOWN, const QuantizationInfo &out_quant_info=QuantizationInfo())
 Adds an activation layer node to the graph. More...
 
static NodeID add_batch_normalization_node (Graph &g, NodeParams params, NodeIdxPair input, float epsilon, ITensorAccessorUPtr mean_accessor=nullptr, ITensorAccessorUPtr var_accessor=nullptr, ITensorAccessorUPtr beta_accessor=nullptr, ITensorAccessorUPtr gamma_accessor=nullptr)
 Adds a batch normalization layer node to the graph. More...
 
static NodeID add_bounding_box_transform_node (Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair deltas, BoundingBoxTransformInfo info)
 Adds a bounding box transform layer node to the graph. More...
 
static NodeID add_channel_shuffle_node (Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_groups)
 Adds an channel shuffle layer node to the graph. More...
 
static NodeID add_convolution_node (Graph &g, NodeParams params, NodeIdxPair input, Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo conv_info, unsigned int num_groups=1, ConvolutionMethod method=ConvolutionMethod::Default, FastMathHint fast_math_hint=FastMathHint::Disabled, ITensorAccessorUPtr weights_accessor=nullptr, ITensorAccessorUPtr bias_accessor=nullptr, const QuantizationInfo &weights_quant_info=QuantizationInfo(), const QuantizationInfo &out_quant_info=QuantizationInfo())
 Adds a convolution layer node to the graph. More...
 
static NodeID add_deconvolution_node (Graph &g, NodeParams params, NodeIdxPair input, Size2D kernel_spatial_extend, unsigned int depth, PadStrideInfo deconv_info, ITensorAccessorUPtr weights_accessor=nullptr, ITensorAccessorUPtr bias_accessor=nullptr)
 Adds a deconvolution layer node to the graph. More...
 
static NodeID add_concatenate_node (Graph &g, NodeParams params, const std::vector< NodeIdxPair > &inputs, const descriptors::ConcatLayerDescriptor &concat_descriptor)
 Adds a depth concatenate node to the graph. More...
 
static NodeID add_depth_to_space_node (Graph &g, NodeParams params, NodeIdxPair input, int32_t block_shape)
 Adds an depth to space layer node to the graph. More...
 
static NodeID add_depthwise_convolution_node (Graph &g, NodeParams params, NodeIdxPair input, Size2D kernel_spatial_extend, PadStrideInfo conv_info, int depth_multiplier=1, DepthwiseConvolutionMethod method=DepthwiseConvolutionMethod::Default, ITensorAccessorUPtr weights_accessor=nullptr, ITensorAccessorUPtr bias_accessor=nullptr, const QuantizationInfo &quant_info=QuantizationInfo(), const QuantizationInfo &out_quant_info=QuantizationInfo())
 Adds a depth-wise convolution layer node to the graph. More...
 
static NodeID add_elementwise_node (Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation)
 Adds an element-wise layer node to the graph. More...
 
static NodeID add_dequantization_node (Graph &g, NodeParams params, NodeIdxPair input)
 Adds a dequantization node to the graph. More...
 
static NodeID add_detection_output_node (Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, const DetectionOutputLayerInfo &detect_info)
 Adds a detection output layer node to the graph. More...
 
static NodeID add_detection_post_process_node (Graph &g, NodeParams params, NodeIdxPair input_box_encoding, NodeIdxPair input_class_prediction, const DetectionPostProcessLayerInfo &detect_info, ITensorAccessorUPtr anchors_accessor=nullptr, const QuantizationInfo &anchor_quant_info=QuantizationInfo())
 Adds a detection post process layer node to the graph. More...
 
static NodeID add_dummy_node (Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape)
 Adds a Dummy node to the graph. More...
 
static NodeID add_flatten_node (Graph &g, NodeParams params, NodeIdxPair input)
 Adds a flatten layer node to the graph. More...
 
static NodeID add_fully_connected_layer (Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs, NodeID weights_nid, NodeID bias_nid=EmptyNodeID, const FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo &out_quant_info=QuantizationInfo(), FastMathHint fast_math_hint=FastMathHint::Disabled)
 Adds a fully connected layer node to the graph. More...
 
static NodeID add_fully_connected_layer (Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs, ITensorAccessorUPtr weights_accessor=nullptr, ITensorAccessorUPtr bias_accessor=nullptr, const FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo &weights_quant_info=QuantizationInfo(), const QuantizationInfo &out_quant_info=QuantizationInfo(), FastMathHint fast_math_hint=FastMathHint::Disabled)
 Adds a fully connected layer node to the graph. More...
 
static NodeID add_generate_proposals_node (Graph &g, NodeParams params, NodeIdxPair scores, NodeIdxPair deltas, NodeIdxPair anchors, GenerateProposalsInfo info)
 Adds a generate proposals layer node to the graph. More...
 
static NodeID add_l2_normalize_node (Graph &g, NodeParams params, NodeIdxPair input, int axis, float epsilon)
 Adds a L2 Normalize layer node to the graph. More...
 
static NodeID add_normalization_node (Graph &g, NodeParams params, NodeIdxPair input, NormalizationLayerInfo norm_info)
 Adds a normalization layer node to the graph. More...
 
static NodeID add_normalize_planar_yuv_node (Graph &g, NodeParams params, NodeIdxPair input, ITensorAccessorUPtr mean_accessor=nullptr, ITensorAccessorUPtr std_accessor=nullptr)
 Adds a normalize planar YUV layer node to the graph. More...
 
static NodeID add_pad_node (Graph &g, NodeParams params, NodeIdxPair input, const PaddingList &paddings, PixelValue pad_value=PixelValue())
 Adds a pad layer node to the graph. More...
 
static NodeID add_permute_node (Graph &g, NodeParams params, NodeIdxPair input, PermutationVector perm, DataLayout layout=DataLayout::UNKNOWN)
 Adds a permute layer node to the graph. More...
 
static NodeID add_pooling_node (Graph &g, NodeParams params, NodeIdxPair input, PoolingLayerInfo pool_info)
 Adds a pooling layer node to the graph. More...
 
static NodeID add_prelu_node (Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair alpha)
 Adds a prelu layer node to the graph. More...
 
static NodeID add_print_node (Graph &g, NodeParams params, NodeIdxPair input, std::ostream &stream, const IOFormatInfo &format_info=IOFormatInfo(), const std::function< ITensor *(ITensor *)> transform=nullptr)
 Adds a print layer node to the graph. More...
 
static NodeID add_priorbox_node (Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, const PriorBoxLayerInfo &prior_info)
 Adds a priorbox layer node to the graph. More...
 
static NodeID add_quantization_node (Graph &g, NodeParams params, NodeIdxPair input, const QuantizationInfo &out_quant_info)
 Adds a quantization layer node to the graph. More...
 
static NodeID add_reduction_operation_node (Graph &g, NodeParams params, NodeIdxPair input, ReductionOperation op, int axis, bool keep_dims=true)
 Adds a reduction sum layer node to the graph. More...
 
static NodeID add_reorg_node (Graph &g, NodeParams params, NodeIdxPair input, int stride)
 Adds a reorg layer node to the graph. More...
 
static NodeID add_reshape_node (Graph &g, NodeParams params, NodeIdxPair input, TensorShape shape)
 Adds a reshape layer node to the graph. More...
 
static NodeID add_resize_node (Graph &g, NodeParams params, NodeIdxPair input, InterpolationPolicy policy, float width_scale, float height_scale)
 Adds a resize layer node to the graph. More...
 
static NodeID add_roi_align_node (Graph &g, NodeParams params, NodeIdxPair input, NodeIdxPair rois, ROIPoolingLayerInfo pool_info)
 Adds a ROI align layer node to the graph. More...
 
static NodeID add_scale_layer (Graph &g, const NodeParams &params, NodeIdxPair input, ITensorAccessorUPtr mul_accessor=nullptr, ITensorAccessorUPtr add_accessor=nullptr)
 Adds a scale layer node to the graph This layer computes a product of the input with a scale (read from mul_accessor) and it applies an offset (read from add_accessor). More...
 
static NodeID add_softmax_node (Graph &g, NodeParams params, NodeIdxPair input, float beta=1.f)
 Adds a softmax node to the graph. More...
 
static NodeID add_slice_node (Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends)
 Adds a slice node to the graph. More...
 
static NodeID add_split_node (Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis=0)
 Adds a split node to the graph. More...
 
static NodeID add_stack_node (Graph &g, NodeParams params, const std::vector< NodeIdxPair > &inputs, int axis)
 Adds a stack layer node to the graph. More...
 
static NodeID add_strided_slice_node (Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends, BiStrides &strides, StridedSliceLayerInfo info)
 Adds a strided slice node to the graph. More...
 
static NodeID add_yolo_node (Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info)
 Adds a yolo layer to the graph. More...
 

Detailed Description

Graph builder class.

Builds and compiles a graph

Definition at line 42 of file GraphBuilder.h.

Member Function Documentation

◆ add_activation_node()

NodeID add_activation_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ActivationLayerInfo  act_info,
const QuantizationInfo out_quant_info = QuantizationInfo() 
)
static

Adds an activation layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the activation layer node as a NodeID-Index pair
[in]act_infoActivation layer information
[in]out_quant_info(Optional) Output quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 137 of file GraphBuilder.cpp.

139 {
140  return create_simple_single_input_output_node<ActivationLayerNode>(g, params, input, act_info, out_quant_info);
141 }

References arm_compute::test::validation::act_info, and arm_compute::test::validation::input.

Referenced by ActivationLayer::create_layer().

◆ add_arg_min_max_node()

NodeID add_arg_min_max_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ReductionOperation  op,
unsigned int  axis,
DataType  out_data_type = DataType::UNKNOWN,
const QuantizationInfo out_quant_info = QuantizationInfo() 
)
static

Adds an activation layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the activation layer node as a NodeID-Index pair
[in]opReduction Operation: min or max
[in]axisAxis to perform reduction operation across
[in]out_data_type(Optional) Output data type
[in]out_quant_info(Optional) Output quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 143 of file GraphBuilder.cpp.

145 {
146  return create_simple_single_input_output_node<ArgMinMaxLayerNode>(g, params, input, op, axis, out_data_type, out_quant_info);
147 }

References arm_compute::test::validation::input.

Referenced by ArgMinMaxLayer::create_layer().

◆ add_batch_normalization_node()

NodeID add_batch_normalization_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
float  epsilon,
ITensorAccessorUPtr  mean_accessor = nullptr,
ITensorAccessorUPtr  var_accessor = nullptr,
ITensorAccessorUPtr  beta_accessor = nullptr,
ITensorAccessorUPtr  gamma_accessor = nullptr 
)
static

Adds a batch normalization layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the batch normalization layer node as a NodeID-Index pair
[in]epsilonEpsilon parameter
[in]mean_accessorConst Node ID that contains the mean values
[in]var_accessorConst Node ID that contains the variance values
[in]beta_accessorConst Node ID that contains the beta values. Can be EmptyNodeID
[in]gamma_accessorConst Node ID that contains the gamma values. Can be EmptyNodeID
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 149 of file GraphBuilder.cpp.

152 {
153  check_nodeidx_pair(input, g);
154 
155  bool has_beta = (beta_accessor != nullptr);
156  bool has_gamma = (gamma_accessor != nullptr);
157 
158  // Get input tensor descriptor
159  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
160 
161  // Calculate Common Descriptor
162  TensorDescriptor common_desc = input_tensor_desc;
163  common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL));
164 
165  // Create mean and var nodes
166  auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor));
167  auto var_nid = add_const_node_with_name(g, params, "Variance", common_desc, std::move(var_accessor));
168 
169  // Create beta node
170  NodeID beta_nid = EmptyNodeID;
171  if(has_beta)
172  {
173  beta_nid = add_const_node_with_name(g, params, "Beta", common_desc, std::move(beta_accessor));
174  }
175 
176  // Create gamma node
177  NodeID gamma_nid = EmptyNodeID;
178  if(has_gamma)
179  {
180  gamma_nid = add_const_node_with_name(g, params, "Gamma", common_desc, std::move(gamma_accessor));
181  }
182 
183  // Create batch normalization node and add connections
184  NodeID batch_norm_nid = g.add_node<BatchNormalizationLayerNode>(epsilon);
185  g.add_connection(input.node_id, input.index, batch_norm_nid, 0);
186  g.add_connection(mean_nid, 0, batch_norm_nid, 1);
187  g.add_connection(var_nid, 0, batch_norm_nid, 2);
188  if(has_beta)
189  {
190  g.add_connection(beta_nid, 0, batch_norm_nid, 3);
191  }
192  if(has_gamma)
193  {
194  g.add_connection(gamma_nid, 0, batch_norm_nid, 4);
195  }
196  set_node_params(g, batch_norm_nid, params);
197 
198  return batch_norm_nid;
199 }

References Graph::add_connection(), Graph::add_node(), arm_compute::CHANNEL, arm_compute::graph::EmptyNodeID, arm_compute::quantization::epsilon, arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::input, Graph::node(), INode::outputs(), and TensorDescriptor::shape.

Referenced by BatchNormalizationLayer::create_layer().

◆ add_bounding_box_transform_node()

NodeID add_bounding_box_transform_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
NodeIdxPair  deltas,
BoundingBoxTransformInfo  info 
)
static

Adds a bounding box transform layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the bounding box transform layer node as a NodeID-Index pair
[in]deltasDeltas input to the bounding box transform layer node as a NodeID-Index pair
[in]infoBounding Box Transform information
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 201 of file GraphBuilder.cpp.

202 {
203  check_nodeidx_pair(input, g);
204  check_nodeidx_pair(deltas, g);
205 
206  NodeID nid = g.add_node<BoundingBoxTransformLayerNode>(info);
207 
208  g.add_connection(input.node_id, input.index, nid, 0);
209  g.add_connection(deltas.node_id, deltas.index, nid, 1);
210 
211  set_node_params(g, nid, params);
212  return nid;
213 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, arm_compute::test::validation::info, arm_compute::test::validation::input, and NodeIdxPair::node_id.

Referenced by BoundingBoxTransformLayer::create_layer().

◆ add_channel_shuffle_node()

NodeID add_channel_shuffle_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
unsigned int  num_groups 
)
static

Adds an channel shuffle layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the activation layer node as a NodeID-Index pair
[in]num_groupsNumber of groups
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 215 of file GraphBuilder.cpp.

216 {
217  return create_simple_single_input_output_node<ChannelShuffleLayerNode>(g, params, input, num_groups);
218 }

References arm_compute::test::validation::input, and arm_compute::test::validation::num_groups.

Referenced by ChannelShuffleLayer::create_layer().

◆ add_concatenate_node()

NodeID add_concatenate_node ( Graph g,
NodeParams  params,
const std::vector< NodeIdxPair > &  inputs,
const descriptors::ConcatLayerDescriptor concat_descriptor 
)
static

Adds a depth concatenate node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputsInputs to the concatenate layer node as a NodeID-Index pair
[in]concat_descriptorConcatenation layer descriptor
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 328 of file GraphBuilder.cpp.

329 {
330  return create_simple_multiple_input_single_output_node<ConcatenateLayerNode>(g, params, inputs, inputs.size(), concat_descriptor);
331 }

Referenced by ConcatLayer::create_layer().

◆ add_const_node()

NodeID add_const_node ( Graph g,
NodeParams  params,
const TensorDescriptor desc,
ITensorAccessorUPtr  accessor = nullptr 
)
static

Adds a Const node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]descTensor descriptor of the node
[in]accessor(Optional) Accessor of the const node data
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 109 of file GraphBuilder.cpp.

110 {
111  auto nid = g.add_node<ConstNode>(desc);
112  set_node_params(g, nid, params);
113  set_accessor_on_node(g, nid, true, 0, std::move(accessor));
114  return nid;
115 }

References Graph::add_node().

Referenced by ConstantLayer::create_layer().

◆ add_convolution_node()

NodeID add_convolution_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
Size2D  kernel_spatial_extend,
unsigned int  depth,
PadStrideInfo  conv_info,
unsigned int  num_groups = 1,
ConvolutionMethod  method = ConvolutionMethod::Default,
FastMathHint  fast_math_hint = FastMathHint::Disabled,
ITensorAccessorUPtr  weights_accessor = nullptr,
ITensorAccessorUPtr  bias_accessor = nullptr,
const QuantizationInfo weights_quant_info = QuantizationInfo(),
const QuantizationInfo out_quant_info = QuantizationInfo() 
)
static

Adds a convolution layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the convolution layer node as a NodeID-Index pair
[in]kernel_spatial_extendSpatial extend of convolution kernels
[in]depthNumber of convolution kernels
[in]conv_infoConvolution layer information
[in]num_groups(Optional) Number of groups for a grouped convolution. Defaults to 1
[in]method(Optional) Convolution method to use
[in]fast_math_hint(Optional) Fast math hint
[in]weights_accessor(Optional) Accessor of the weights node data
[in]bias_accessor(Optional) Accessor of the bias node data
[in]weights_quant_info(Optional) Weights quantization info
[in]out_quant_info(Optional) Output quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 220 of file GraphBuilder.cpp.

226 {
227  check_nodeidx_pair(input, g);
228  ARM_COMPUTE_ERROR_ON(depth == 0);
229  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
230 
231  bool has_bias = (bias_accessor != nullptr);
232 
233  // Get input tensor descriptor
234  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
235  const DataLayout input_data_layout = input_tensor_desc.layout;
236 
237  // Create weights node
238  TensorDescriptor w_desc = input_tensor_desc;
239  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
240  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
241  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
243  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::BATCHES), depth);
244  if(!weights_quant_info.empty())
245  {
246  w_desc.quant_info = weights_quant_info;
247  }
248 
249  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
250 
251  // Create bias nodes
252  NodeID b_nid = EmptyNodeID;
253  if(has_bias)
254  {
255  TensorDescriptor b_desc = input_tensor_desc;
256  b_desc.shape = TensorShape(depth);
257  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
258  {
259  b_desc.data_type = DataType::S32;
260  }
261  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
262  }
263 
264  // Create convolution node and connect
265  NodeID conv_nid = g.add_node<ConvolutionLayerNode>(conv_info, num_groups, method, fast_math_hint, out_quant_info);
266  g.add_connection(input.node_id, input.index, conv_nid, 0);
267  g.add_connection(w_nid, 0, conv_nid, 1);
268  if(has_bias)
269  {
270  g.add_connection(b_nid, 0, conv_nid, 2);
271  }
272  set_node_params(g, conv_nid, params);
273 
274  return conv_nid;
275 }

References Graph::add_connection(), Graph::add_node(), ARM_COMPUTE_ERROR_ON, arm_compute::BATCHES, arm_compute::CHANNEL, arm_compute::test::validation::conv_info, TensorDescriptor::data_type, QuantizationInfo::empty(), arm_compute::graph::EmptyNodeID, arm_compute::graph::get_dimension_idx(), arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::has_bias, Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), arm_compute::test::validation::num_groups, INode::outputs(), TensorDescriptor::quant_info, arm_compute::S32, TensorShape::set(), TensorDescriptor::shape, Size2D::width, and arm_compute::WIDTH.

Referenced by ConvolutionLayer::create_layer().

◆ add_deconvolution_node()

NodeID add_deconvolution_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
Size2D  kernel_spatial_extend,
unsigned int  depth,
PadStrideInfo  deconv_info,
ITensorAccessorUPtr  weights_accessor = nullptr,
ITensorAccessorUPtr  bias_accessor = nullptr 
)
static

Adds a deconvolution layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the convolution layer node as a NodeID-Index pair
[in]kernel_spatial_extendSpatial extend of convolution kernels
[in]depthNumber of convolution kernels
[in]deconv_infoConvolution layer information
[in]weights_accessor(Optional) Accessor of the weights node data
[in]bias_accessor(Optional) Accessor of the bias node data
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 277 of file GraphBuilder.cpp.

281 {
282  check_nodeidx_pair(input, g);
283  ARM_COMPUTE_ERROR_ON(depth == 0);
284  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
285 
286  bool has_bias = (bias_accessor != nullptr);
287 
288  // Get input tensor descriptor
289  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
290  const DataLayout input_data_layout = input_tensor_desc.layout;
291 
292  // Create weights node
293  TensorDescriptor w_desc = input_tensor_desc;
294  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
295  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
296  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
298  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::BATCHES), depth);
299 
300  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
301 
302  // Create bias nodes
303  NodeID b_nid = EmptyNodeID;
304  if(has_bias)
305  {
306  TensorDescriptor b_desc = input_tensor_desc;
307  b_desc.shape = TensorShape(depth);
308  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
309  {
310  b_desc.data_type = DataType::S32;
311  }
312  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
313  }
314 
315  // Create convolution node and connect
316  NodeID deconv_nid = g.add_node<DeconvolutionLayerNode>(descriptors::DeconvolutionLayerDescriptor{ deconv_info });
317  g.add_connection(input.node_id, input.index, deconv_nid, 0);
318  g.add_connection(w_nid, 0, deconv_nid, 1);
319  if(has_bias)
320  {
321  g.add_connection(b_nid, 0, deconv_nid, 2);
322  }
323  set_node_params(g, deconv_nid, params);
324 
325  return deconv_nid;
326 }

References Graph::add_connection(), Graph::add_node(), ARM_COMPUTE_ERROR_ON, arm_compute::BATCHES, arm_compute::CHANNEL, TensorDescriptor::data_type, arm_compute::graph::EmptyNodeID, arm_compute::graph::get_dimension_idx(), arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::has_bias, Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), INode::outputs(), arm_compute::S32, TensorShape::set(), TensorDescriptor::shape, Size2D::width, and arm_compute::WIDTH.

Referenced by DeconvolutionLayer::create_layer().

◆ add_depth_to_space_node()

NodeID add_depth_to_space_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
int32_t  block_shape 
)
static

Adds an depth to space layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the depth to space layer node as a NodeID-Index pair
[in]block_shapeBlock shape to reshape tensor with
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 387 of file GraphBuilder.cpp.

388 {
389  return create_simple_single_input_output_node<DepthToSpaceLayerNode>(g, params, input, block_shape);
390 }

References arm_compute::test::validation::input.

Referenced by DepthToSpaceLayer::create_layer().

◆ add_depthwise_convolution_node()

NodeID add_depthwise_convolution_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
Size2D  kernel_spatial_extend,
PadStrideInfo  conv_info,
int  depth_multiplier = 1,
DepthwiseConvolutionMethod  method = DepthwiseConvolutionMethod::Default,
ITensorAccessorUPtr  weights_accessor = nullptr,
ITensorAccessorUPtr  bias_accessor = nullptr,
const QuantizationInfo quant_info = QuantizationInfo(),
const QuantizationInfo out_quant_info = QuantizationInfo() 
)
static

Adds a depth-wise convolution layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the depthwise convolution layer node as a NodeID-Index pair
[in]kernel_spatial_extendSpatial extend of convolution kernels
[in]conv_infoConvolution layer information
[in]depth_multiplier(Optional) Depth multiplier parameter.
[in]method(Optional) Convolution method to use
[in]weights_accessor(Optional) Accessor of the weights node data
[in]bias_accessor(Optional) Accessor of the bias node data
[in]quant_info(Optional) Weights quantization info
[in]out_quant_info(Optional) Output quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 333 of file GraphBuilder.cpp.

336 {
337  check_nodeidx_pair(input, g);
338  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
339 
340  bool has_bias = (bias_accessor != nullptr);
341 
342  // Get input tensor descriptor
343  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
344  const DataLayout input_data_layout = input_tensor_desc.layout;
345 
346  // Create weights node
347  TensorDescriptor w_desc = input_tensor_desc;
348  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
349  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
350  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
351  get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier);
352  if(!quant_info.empty())
353  {
354  w_desc.quant_info = quant_info;
355  }
356 
357  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
358 
359  // Create bias nodes
360  NodeID b_nid = EmptyNodeID;
361  if(has_bias)
362  {
363  TensorDescriptor b_desc = input_tensor_desc;
364  b_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier);
365 
366  if(is_data_type_quantized_asymmetric(b_desc.data_type))
367  {
368  b_desc.data_type = DataType::S32;
369  }
370 
371  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
372  }
373 
374  // Create convolution node and connect
375  NodeID conv_nid = g.add_node<DepthwiseConvolutionLayerNode>(conv_info, depth_multiplier, method, out_quant_info);
376  g.add_connection(input.node_id, input.index, conv_nid, 0);
377  g.add_connection(w_nid, 0, conv_nid, 1);
378  if(has_bias)
379  {
380  g.add_connection(b_nid, 0, conv_nid, 2);
381  }
382  set_node_params(g, conv_nid, params);
383 
384  return conv_nid;
385 }

References Graph::add_connection(), Graph::add_node(), ARM_COMPUTE_ERROR_ON, arm_compute::CHANNEL, arm_compute::test::validation::conv_info, TensorDescriptor::data_type, QuantizationInfo::empty(), arm_compute::graph::EmptyNodeID, arm_compute::graph::get_dimension_idx(), arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::has_bias, Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), INode::outputs(), TensorDescriptor::quant_info, arm_compute::S32, TensorShape::set(), TensorDescriptor::shape, Size2D::width, and arm_compute::WIDTH.

Referenced by DepthwiseConvolutionLayer::create_layer().

◆ add_dequantization_node()

NodeID add_dequantization_node ( Graph g,
NodeParams  params,
NodeIdxPair  input 
)
static

Adds a dequantization node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the dequantization node as a NodeID-Index pair
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 392 of file GraphBuilder.cpp.

393 {
394  return create_simple_single_input_output_node<DequantizationLayerNode>(g, params, input);
395 }

References arm_compute::test::validation::input.

Referenced by DequantizationLayer::create_layer().

◆ add_detection_output_node()

NodeID add_detection_output_node ( Graph g,
NodeParams  params,
NodeIdxPair  input_loc,
NodeIdxPair  input_conf,
NodeIdxPair  input_priorbox,
const DetectionOutputLayerInfo detect_info 
)
static

Adds a detection output layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]input_locLocation input to the detection output layer node as a NodeID-Index pair
[in]input_confConfidence input to the detection output layer node as a NodeID-Index pair
[in]input_priorboxPriorBox input to the detection output layer node as a NodeID-Index pair
[in]detect_infoDetection output layer parameters
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 397 of file GraphBuilder.cpp.

398 {
399  check_nodeidx_pair(input_loc, g);
400  check_nodeidx_pair(input_conf, g);
401  check_nodeidx_pair(input_priorbox, g);
402 
403  // Create detection_output node and connect
404  NodeID detect_nid = g.add_node<DetectionOutputLayerNode>(detect_info);
405  g.add_connection(input_loc.node_id, input_loc.index, detect_nid, 0);
406  g.add_connection(input_conf.node_id, input_conf.index, detect_nid, 1);
407  g.add_connection(input_priorbox.node_id, input_priorbox.index, detect_nid, 2);
408 
409  set_node_params(g, detect_nid, params);
410 
411  return detect_nid;
412 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, and NodeIdxPair::node_id.

Referenced by DetectionOutputLayer::create_layer().

◆ add_detection_post_process_node()

NodeID add_detection_post_process_node ( Graph g,
NodeParams  params,
NodeIdxPair  input_box_encoding,
NodeIdxPair  input_class_prediction,
const DetectionPostProcessLayerInfo detect_info,
ITensorAccessorUPtr  anchors_accessor = nullptr,
const QuantizationInfo anchor_quant_info = QuantizationInfo() 
)
static

Adds a detection post process layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]input_box_encodingBoxes input to the detection output layer node as a NodeID-Index pair
[in]input_class_predictionClass prediction input to the detection output layer node as a NodeID-Index pair
[in]detect_infoDetection output layer parameters
[in]anchors_accessor(Optional) Const Node ID that contains the anchor values
[in]anchor_quant_info(Optional) Anchor quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 414 of file GraphBuilder.cpp.

416 {
417  check_nodeidx_pair(input_box_encoding, g);
418  check_nodeidx_pair(input_class_prediction, g);
419 
420  // Get input tensor descriptor
421  const TensorDescriptor input_box_encoding_tensor_desc = get_tensor_descriptor(g, g.node(input_box_encoding.node_id)->outputs()[0]);
422 
423  // Calculate anchor descriptor
424  TensorDescriptor anchor_desc = input_box_encoding_tensor_desc;
425  if(!anchor_quant_info.empty())
426  {
427  anchor_desc.quant_info = anchor_quant_info;
428  }
429 
430  // Create anchors nodes
431  auto anchors_nid = add_const_node_with_name(g, params, "Anchors", anchor_desc, std::move(anchors_accessor));
432 
433  // Create detection_output node and connect
434  NodeID detect_nid = g.add_node<DetectionPostProcessLayerNode>(detect_info);
435  g.add_connection(input_box_encoding.node_id, input_box_encoding.index, detect_nid, 0);
436  g.add_connection(input_class_prediction.node_id, input_class_prediction.index, detect_nid, 1);
437  g.add_connection(anchors_nid, 0, detect_nid, 2);
438 
439  set_node_params(g, detect_nid, params);
440 
441  return detect_nid;
442 }

References Graph::add_connection(), Graph::add_node(), QuantizationInfo::empty(), arm_compute::graph::get_tensor_descriptor(), NodeIdxPair::index, Graph::node(), NodeIdxPair::node_id, INode::outputs(), and TensorDescriptor::quant_info.

Referenced by DetectionPostProcessLayer::create_layer().

◆ add_dummy_node()

NodeID add_dummy_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
TensorShape  shape 
)
static

Adds a Dummy node to the graph.

Note
this node if for debugging purposes. Just alters the shape of the graph pipeline as requested.
Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the dummy node as a NodeID-Index pair
[in]shapeOutput shape
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 444 of file GraphBuilder.cpp.

445 {
446  return create_simple_single_input_output_node<DummyNode>(g, params, input, shape);
447 }

References arm_compute::test::validation::input, and arm_compute::test::validation::shape.

Referenced by DummyLayer::create_layer().

◆ add_elementwise_node()

NodeID add_elementwise_node ( Graph g,
NodeParams  params,
NodeIdxPair  input0,
NodeIdxPair  input1,
EltwiseOperation  operation 
)
static

Adds an element-wise layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]input0First input to the element-wise operation layer node as a NodeID-Index pair
[in]input1Second input to the element-wise operation layer node as a NodeID-Index pair
[in]operationElement-wise operation to perform
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 449 of file GraphBuilder.cpp.

450 {
451  check_nodeidx_pair(input0, g);
452  check_nodeidx_pair(input1, g);
453 
454  NodeID nid = g.add_node<EltwiseLayerNode>(descriptors::EltwiseLayerDescriptor{ operation });
455 
456  g.add_connection(input0.node_id, input0.index, nid, 0);
457  g.add_connection(input1.node_id, input1.index, nid, 1);
458 
459  set_node_params(g, nid, params);
460 
461  return nid;
462 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, and NodeIdxPair::node_id.

Referenced by GraphBuilder::add_scale_layer(), and EltwiseLayer::create_layer().

◆ add_flatten_node()

NodeID add_flatten_node ( Graph g,
NodeParams  params,
NodeIdxPair  input 
)
static

Adds a flatten layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the flatten layer node as a NodeID-Index pair
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 464 of file GraphBuilder.cpp.

465 {
466  return create_simple_single_input_output_node<FlattenLayerNode>(g, params, input);
467 }

References arm_compute::test::validation::input.

Referenced by FlattenLayer::create_layer().

◆ add_fully_connected_layer() [1/2]

NodeID add_fully_connected_layer ( Graph g,
NodeParams  params,
NodeIdxPair  input,
unsigned int  num_outputs,
ITensorAccessorUPtr  weights_accessor = nullptr,
ITensorAccessorUPtr  bias_accessor = nullptr,
const FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo(),
const QuantizationInfo weights_quant_info = QuantizationInfo(),
const QuantizationInfo out_quant_info = QuantizationInfo(),
FastMathHint  fast_math_hint = FastMathHint::Disabled 
)
static

Adds a fully connected layer node to the graph.

Parameters
[in]gGraph to add the layer to
[in]paramsCommon node parameters
[in]inputInput to the fully connected layer node as a NodeID-Index pair
[in]num_outputsNumber of output neurons
[in]weights_accessor(Optional) Accessor of the weights node data
[in]bias_accessor(Optional) Accessor of the bias node data
[in]fc_info(Optional) Fully connected layer metadata
[in]weights_quant_info(Optional) Weights quantization info
[in]out_quant_info(Optional) Output quantization info
[in]fast_math_hint(Optional) Fast math hint
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 496 of file GraphBuilder.cpp.

500 {
501  check_nodeidx_pair(input, g);
502  ARM_COMPUTE_ERROR_ON(num_outputs == 0);
503 
504  bool has_bias = (bias_accessor != nullptr);
505 
506  // Get input tensor descriptor
507  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
508 
509  // Create weights node
510  TensorDescriptor w_desc = FullyConnectedLayerNode::compute_weights_descriptor(input_tensor_desc, num_outputs, fc_info, weights_quant_info);
511  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
512 
513  // Create bias nodes
514  NodeID b_nid = EmptyNodeID;
515  if(has_bias)
516  {
517  TensorDescriptor b_desc = input_tensor_desc;
518  b_desc.shape = TensorShape(num_outputs);
519  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
520  {
521  b_desc.data_type = DataType::S32;
522  }
523  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
524  }
525 
526  // Create fully connected node and connect
527  NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info, fast_math_hint);
528  g.add_connection(input.node_id, input.index, fc_nid, 0);
529  g.add_connection(w_nid, 0, fc_nid, 1);
530  if(has_bias)
531  {
532  g.add_connection(b_nid, 0, fc_nid, 2);
533  }
534 
535  set_node_params(g, fc_nid, params);
536 
537  return fc_nid;
538 }

References Graph::add_connection(), Graph::add_node(), ARM_COMPUTE_ERROR_ON, FullyConnectedLayerNode::compute_weights_descriptor(), TensorDescriptor::data_type, arm_compute::graph::EmptyNodeID, arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::has_bias, arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), Graph::node(), INode::outputs(), arm_compute::S32, and TensorDescriptor::shape.

◆ add_fully_connected_layer() [2/2]

NodeID add_fully_connected_layer ( Graph g,
NodeParams  params,
NodeIdxPair  input,
unsigned int  num_outputs,
NodeID  weights_nid,
NodeID  bias_nid = EmptyNodeID,
const FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo(),
const QuantizationInfo out_quant_info = QuantizationInfo(),
FastMathHint  fast_math_hint = FastMathHint::Disabled 
)
static

Adds a fully connected layer node to the graph.

Parameters
[in]gGraph to add the layer to
[in]paramsCommon node parameters
[in]inputInput to the fully connected layer node as a NodeID-Index pair
[in]num_outputsNumber of output neurons
[in]weights_nidNode ID of the weights node data
[in]bias_nid(Optional) Node ID of the bias node data. Defaults to EmptyNodeID
[in]fc_info(Optional) Fully connected layer metadata
[in]out_quant_info(Optional) Output quantization info
[in]fast_math_hint(Optional) Fast math hint
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 469 of file GraphBuilder.cpp.

472 {
473  check_nodeidx_pair(input, g);
474  ARM_COMPUTE_ERROR_ON(num_outputs == 0);
475  ARM_COMPUTE_ERROR_ON(weights_nid == EmptyNodeID);
476 
477  const bool has_bias = (bias_nid != EmptyNodeID);
478 
479  // Get input tensor descriptor
480  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
481 
482  // Create fully connected node and connect
483  NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info, fast_math_hint);
484  g.add_connection(input.node_id, input.index, fc_nid, 0);
485  g.add_connection(weights_nid, 0, fc_nid, 1);
486  if(has_bias)
487  {
488  g.add_connection(bias_nid, 0, fc_nid, 2);
489  }
490 
491  set_node_params(g, fc_nid, params);
492 
493  return fc_nid;
494 }

References Graph::add_connection(), Graph::add_node(), ARM_COMPUTE_ERROR_ON, arm_compute::graph::EmptyNodeID, arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::has_bias, arm_compute::test::validation::input, Graph::node(), and INode::outputs().

Referenced by FullyConnectedLayer::create_layer().

◆ add_generate_proposals_node()

NodeID add_generate_proposals_node ( Graph g,
NodeParams  params,
NodeIdxPair  scores,
NodeIdxPair  deltas,
NodeIdxPair  anchors,
GenerateProposalsInfo  info 
)
static

Adds a generate proposals layer node to the graph.

Parameters
[in]gGraph to add the layer to
[in]paramsCommon node parameters
[in]scoresInput scores to the generate proposals layer node as a NodeID-Index pair
[in]deltasInput deltas to the generate proposals layer node as a NodeID-Index pair
[in]anchorsInput anchors to the generate proposals layer node as a NodeID-Index pair
[in]infoGenerate proposals operation information
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 540 of file GraphBuilder.cpp.

541 {
542  check_nodeidx_pair(scores, g);
543  check_nodeidx_pair(deltas, g);
544  check_nodeidx_pair(anchors, g);
545 
546  NodeID nid = g.add_node<GenerateProposalsLayerNode>(info);
547 
548  g.add_connection(scores.node_id, scores.index, nid, 0);
549  g.add_connection(deltas.node_id, deltas.index, nid, 1);
550  g.add_connection(anchors.node_id, anchors.index, nid, 2);
551 
552  set_node_params(g, nid, params);
553  return nid;
554 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, arm_compute::test::validation::info, and NodeIdxPair::node_id.

Referenced by GenerateProposalsLayer::create_layer().

◆ add_input_node()

NodeID add_input_node ( Graph g,
NodeParams  params,
const TensorDescriptor desc,
ITensorAccessorUPtr  accessor = nullptr 
)
static

Adds an input layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]descTensor descriptor of the Tensor
[in]accessor(Optional) Accessor of the input node data
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 117 of file GraphBuilder.cpp.

118 {
119  auto nid = g.add_node<InputNode>(desc);
120  set_node_params(g, nid, params);
121  set_accessor_on_node(g, nid, true, 0, std::move(accessor));
122  return nid;
123 }

References Graph::add_node().

Referenced by InputLayer::create_layer().

◆ add_l2_normalize_node()

NodeID add_l2_normalize_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
int  axis,
float  epsilon 
)
static

Adds a L2 Normalize layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the normalization layer node as a NodeID-Index pair
[in]axisAxis to perform normalization on
[in]epsilonLower bound value for the normalization
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 556 of file GraphBuilder.cpp.

557 {
558  return create_simple_single_input_output_node<L2NormalizeLayerNode>(g, params, input, axis, epsilon);
559 }

References arm_compute::quantization::epsilon, and arm_compute::test::validation::input.

Referenced by L2NormalizeLayer::create_layer().

◆ add_normalization_node()

NodeID add_normalization_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
NormalizationLayerInfo  norm_info 
)
static

Adds a normalization layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the normalization layer node as a NodeID-Index pair
[in]norm_infoNormalization layer information
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 561 of file GraphBuilder.cpp.

562 {
563  return create_simple_single_input_output_node<NormalizationLayerNode>(g, params, input, norm_info);
564 }

References arm_compute::test::validation::input.

Referenced by NormalizationLayer::create_layer().

◆ add_normalize_planar_yuv_node()

NodeID add_normalize_planar_yuv_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ITensorAccessorUPtr  mean_accessor = nullptr,
ITensorAccessorUPtr  std_accessor = nullptr 
)
static

Adds a normalize planar YUV layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the normalize planar YUV layer node as a NodeID-Index pair
[in]mean_accessorConst Node ID that contains the mean values
[in]std_accessorConst Node ID that contains the variance values
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 566 of file GraphBuilder.cpp.

568 {
569  check_nodeidx_pair(input, g);
570 
571  // Get input tensor descriptor
572  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
573 
574  // Calculate Common Descriptor
575  TensorDescriptor common_desc = input_tensor_desc;
576  common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL));
577 
578  // Create mean and std nodes
579  auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor));
580  auto std_nid = add_const_node_with_name(g, params, "Std", common_desc, std::move(std_accessor));
581 
582  // Create normalize planar YUV node and add connections
583  NodeID norm_planar_yuv_nid = g.add_node<NormalizePlanarYUVLayerNode>();
584  g.add_connection(input.node_id, input.index, norm_planar_yuv_nid, 0);
585  g.add_connection(mean_nid, 0, norm_planar_yuv_nid, 1);
586  g.add_connection(std_nid, 0, norm_planar_yuv_nid, 2);
587  set_node_params(g, norm_planar_yuv_nid, params);
588 
589  return norm_planar_yuv_nid;
590 }

References Graph::add_connection(), Graph::add_node(), arm_compute::CHANNEL, arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::input, Graph::node(), INode::outputs(), and TensorDescriptor::shape.

Referenced by NormalizePlanarYUVLayer::create_layer().

◆ add_output_node()

NodeID add_output_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ITensorAccessorUPtr  accessor = nullptr 
)
static

Adds an output layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the output node as a NodeID-Index pair
[in]accessor(Optional) Accessor of the output node data
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 125 of file GraphBuilder.cpp.

126 {
127  check_nodeidx_pair(input, g);
128 
129  NodeID nid = g.add_node<OutputNode>();
130  g.add_connection(input.node_id, input.index, nid, 0);
131  set_node_params(g, nid, params);
132  set_accessor_on_node(g, nid, false, 0, std::move(accessor));
133 
134  return nid;
135 }

References Graph::add_connection(), Graph::add_node(), and arm_compute::test::validation::input.

Referenced by OutputLayer::create_layer().

◆ add_pad_node()

NodeID add_pad_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
const PaddingList paddings,
PixelValue  pad_value = PixelValue() 
)
static

Adds a pad layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reshape layer node as a NodeID-Index pair
[in]paddingsThe padding for each spatial dimension of the input tensor. The pair padding[i] specifies the front and the end padding in the i-th dimension.
[in]pad_valuePadding value to be used. Defaults to 0
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 592 of file GraphBuilder.cpp.

593 {
594  return create_simple_single_input_output_node<PadLayerNode>(g, params, input, paddings, pad_value);
595 }

References arm_compute::test::validation::input.

Referenced by PadLayer::create_layer().

◆ add_permute_node()

NodeID add_permute_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
PermutationVector  perm,
DataLayout  layout = DataLayout::UNKNOWN 
)
static

Adds a permute layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reshape layer node as a NodeID-Index pair
[in]permPermutation vector
[in]layout(Optional) Data layout to assign to permuted tensor. If UNKNOWN then the input's layout will be used.
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 597 of file GraphBuilder.cpp.

598 {
599  return create_simple_single_input_output_node<PermuteLayerNode>(g, params, input, perm, layout);
600 }

References arm_compute::test::validation::input.

Referenced by PermuteLayer::create_layer().

◆ add_pooling_node()

NodeID add_pooling_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
PoolingLayerInfo  pool_info 
)
static

Adds a pooling layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the pooling layer node as a NodeID-Index pair
[in]pool_infoPooling layer information
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 616 of file GraphBuilder.cpp.

617 {
618  return create_simple_single_input_output_node<PoolingLayerNode>(g, params, input, pool_info);
619 }

References arm_compute::test::validation::input.

Referenced by PoolingLayer::create_layer().

◆ add_prelu_node()

NodeID add_prelu_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
NodeIdxPair  alpha 
)
static

Adds a prelu layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the PRelu node as a NodeID-Index pair
[in]alphaAlpha input to the PRelu node as a NodeID-Index pair
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 602 of file GraphBuilder.cpp.

603 {
604  check_nodeidx_pair(input, g);
605  check_nodeidx_pair(alpha, g);
606 
607  NodeID prelu_nid = g.add_node<PReluLayerNode>();
608  g.add_connection(input.node_id, input.index, prelu_nid, 0);
609  g.add_connection(alpha.node_id, alpha.index, prelu_nid, 1);
610 
611  set_node_params(g, prelu_nid, params);
612 
613  return prelu_nid;
614 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, arm_compute::test::validation::input, and NodeIdxPair::node_id.

Referenced by PReluLayer::create_layer().

◆ add_print_node()

NodeID add_print_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
std::ostream &  stream,
const IOFormatInfo format_info = IOFormatInfo(),
const std::function< ITensor *(ITensor *)>  transform = nullptr 
)
static

Adds a print layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the print layer node as a NodeID-Index pair
[in]streamOutput stream.
[in]format_info(Optional) Format info.
[in]transform(Optional) Transformation function to be applied to the input tensor before printing.
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 621 of file GraphBuilder.cpp.

622 {
623  return create_simple_single_input_output_node<PrintLayerNode>(g, params, input, stream, format_info, transform);
624 }

References arm_compute::test::validation::input.

Referenced by PrintLayer::create_layer().

◆ add_priorbox_node()

NodeID add_priorbox_node ( Graph g,
NodeParams  params,
NodeIdxPair  input0,
NodeIdxPair  input1,
const PriorBoxLayerInfo prior_info 
)
static

Adds a priorbox layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]input0First input to the priorbox layer node as a NodeID-Index pair
[in]input1Second input to the priorbox layer node as a NodeID-Index pair
[in]prior_infoPriorBox parameters
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 626 of file GraphBuilder.cpp.

627 {
628  check_nodeidx_pair(input0, g);
629  check_nodeidx_pair(input1, g);
630 
631  // Create priorbox node and connect
632  NodeID prior_nid = g.add_node<PriorBoxLayerNode>(prior_info);
633  g.add_connection(input0.node_id, input0.index, prior_nid, 0);
634  g.add_connection(input1.node_id, input1.index, prior_nid, 1);
635 
636  set_node_params(g, prior_nid, params);
637 
638  return prior_nid;
639 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, and NodeIdxPair::node_id.

Referenced by PriorBoxLayer::create_layer().

◆ add_quantization_node()

NodeID add_quantization_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
const QuantizationInfo out_quant_info 
)
static

Adds a quantization layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the quantization layer node as a NodeID-Index pair
[in]out_quant_infoOutput quantization info
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 641 of file GraphBuilder.cpp.

642 {
643  return create_simple_single_input_output_node<QuantizationLayerNode>(g, params, input, out_quant_info);
644 }

References arm_compute::test::validation::input.

Referenced by QuantizationLayer::create_layer().

◆ add_reduction_operation_node()

NodeID add_reduction_operation_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ReductionOperation  op,
int  axis,
bool  keep_dims = true 
)
static

Adds a reduction sum layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reorg layer node as a NodeID-Index pair
[in]opReduction operation
[in]axisReduction axis
[in]keep_dims(Optional) Whether to keep the reduced dimension after the operation. Defaults to true.
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 646 of file GraphBuilder.cpp.

647 {
648  return create_simple_single_input_output_node<ReductionLayerNode>(g, params, input, op, axis, keep_dims);
649 }

References arm_compute::test::validation::input.

Referenced by ReductionLayer::create_layer().

◆ add_reorg_node()

NodeID add_reorg_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
int  stride 
)
static

Adds a reorg layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reorg layer node as a NodeID-Index pair
[in]strideStride value to use for reorganizing the values in the output tensor.
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 651 of file GraphBuilder.cpp.

652 {
653  return create_simple_single_input_output_node<ReorgLayerNode>(g, params, input, stride);
654 }

References arm_compute::test::validation::input.

Referenced by ReorgLayer::create_layer().

◆ add_reshape_node()

NodeID add_reshape_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
TensorShape  shape 
)
static

Adds a reshape layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reshape layer node as a NodeID-Index pair
[in]shapeOutput reshaped shape
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 656 of file GraphBuilder.cpp.

657 {
658  return create_simple_single_input_output_node<ReshapeLayerNode>(g, params, input, shape);
659 }

References arm_compute::test::validation::input, and arm_compute::test::validation::shape.

Referenced by ReshapeLayer::create_layer().

◆ add_resize_node()

NodeID add_resize_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
InterpolationPolicy  policy,
float  width_scale,
float  height_scale 
)
static

Adds a resize layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reshape layer node as a NodeID-Index pair
[in]policyInterpolation policy
[in]width_scaleWidth scaling factor
[in]height_scaleHeight scaling factor
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 661 of file GraphBuilder.cpp.

663 {
664  return create_simple_single_input_output_node<ResizeLayerNode>(g, params, input, policy, width_scale, height_scale);
665 }

References arm_compute::test::validation::input.

Referenced by ResizeLayer::create_layer().

◆ add_roi_align_node()

NodeID add_roi_align_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
NodeIdxPair  rois,
ROIPoolingLayerInfo  pool_info 
)
static

Adds a ROI align layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the reshape layer node as a NodeID-Index pair
[in]roisInput containing the ROIs.
[in]pool_infoContains pooling operation information described in ROIPoolingLayerInfo.
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 667 of file GraphBuilder.cpp.

668 {
669  check_nodeidx_pair(input, g);
670  check_nodeidx_pair(rois, g);
671 
672  NodeID nid = g.add_node<ROIAlignLayerNode>(pool_info);
673 
674  g.add_connection(input.node_id, input.index, nid, 0);
675  g.add_connection(rois.node_id, rois.index, nid, 1);
676 
677  set_node_params(g, nid, params);
678  return nid;
679 }

References Graph::add_connection(), Graph::add_node(), NodeIdxPair::index, arm_compute::test::validation::input, and NodeIdxPair::node_id.

Referenced by ROIAlignLayer::create_layer().

◆ add_scale_layer()

NodeID add_scale_layer ( Graph g,
const NodeParams params,
NodeIdxPair  input,
ITensorAccessorUPtr  mul_accessor = nullptr,
ITensorAccessorUPtr  add_accessor = nullptr 
)
static

Adds a scale layer node to the graph This layer computes a product of the input with a scale (read from mul_accessor) and it applies an offset (read from add_accessor).

output = input * mul_w + add_w

Parameters
[in]gGraph to add the layer to
[in]paramsCommon node parameters
[in]inputInput to the fully connected layer node as a NodeID-Index pair
[in]mul_accessor(Optional) Accessor of the mul node data
[in]add_accessor(Optional) Accessor of the add node data
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 681 of file GraphBuilder.cpp.

682 {
683  check_nodeidx_pair(input, g);
684 
685  // Get input tensor descriptor
686  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
687  const DataLayout input_data_layout = input_tensor_desc.layout;
688 
689  // Create mul node
690  TensorDescriptor mul_desc = input_tensor_desc;
691  const size_t C = input_tensor_desc.shape[get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL)];
692  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), 1);
693  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), 1);
694  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL), C);
695  NodeID mul_const_nid = add_const_node_with_name(g, params, "Mul", mul_desc, std::move(mul_accessor));
696  NodeIdxPair mul_const_nidxp = { mul_const_nid, 0 };
697 
698  // Create add node
699  TensorDescriptor add_desc = mul_desc;
700  NodeID add_const_nid = add_const_node_with_name(g, params, "Add", add_desc, std::move(add_accessor));
701  NodeIdxPair add_const_nidxp = { add_const_nid, 0 };
702 
703  // Create node and connect
704  NodeID mul_node = GraphBuilder::add_elementwise_node(g, params, input, mul_const_nidxp, EltwiseOperation::Mul);
705  NodeIdxPair mulnode_nidxp = { mul_node, 0 };
706  NodeID add_node = GraphBuilder::add_elementwise_node(g, params, mulnode_nidxp, add_const_nidxp, EltwiseOperation::Add);
707 
708  return add_node;
709 }

References arm_compute::graph::Add, GraphBuilder::add_elementwise_node(), arm_compute::CHANNEL, arm_compute::graph::get_dimension_idx(), arm_compute::graph::get_tensor_descriptor(), arm_compute::HEIGHT, arm_compute::test::validation::input, TensorDescriptor::layout, arm_compute::graph::Mul, Graph::node(), INode::outputs(), TensorShape::set(), TensorDescriptor::shape, and arm_compute::WIDTH.

Referenced by ScaleLayer::create_layer().

◆ add_slice_node()

NodeID add_slice_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
Coordinates starts,
Coordinates ends 
)
static

Adds a slice node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the slice layer node as a NodeID-Index pair
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 716 of file GraphBuilder.cpp.

717 {
718  return create_simple_single_input_output_node<SliceLayerNode>(g, params, input, starts, ends);
719 }

References arm_compute::test::validation::input.

Referenced by SliceLayer::create_layer().

◆ add_softmax_node()

NodeID add_softmax_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
float  beta = 1.f 
)
static

Adds a softmax node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the softmax layer node as a NodeID-Index pair
[in]betaBeta parameter
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 711 of file GraphBuilder.cpp.

712 {
713  return create_simple_single_input_output_node<SoftmaxLayerNode>(g, params, input, beta);
714 }

References arm_compute::test::validation::input.

Referenced by SoftmaxLayer::create_layer().

◆ add_split_node()

NodeID add_split_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
unsigned int  num_splits,
unsigned int  axis = 0 
)
static

Adds a split node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the split layer node as a NodeID-Index pair
[in]num_splitsNumber of different splits
[in]axis(Optional) Split axis. Defaults to 0
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 721 of file GraphBuilder.cpp.

722 {
723  return create_simple_single_input_output_node<SplitLayerNode>(g, params, input, num_splits, axis);
724 }

References arm_compute::test::validation::input.

◆ add_stack_node()

NodeID add_stack_node ( Graph g,
NodeParams  params,
const std::vector< NodeIdxPair > &  inputs,
int  axis 
)
static

Adds a stack layer node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputsInputs to the reorg layer node as a NodeID-Index pair
[in]axisAxis along which the input tensors have to be packed
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 731 of file GraphBuilder.cpp.

732 {
733  return create_simple_multiple_input_single_output_node<StackLayerNode>(g, params, inputs, inputs.size(), axis);
734 }

Referenced by StackLayer::create_layer().

◆ add_strided_slice_node()

NodeID add_strided_slice_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
Coordinates starts,
Coordinates ends,
BiStrides strides,
StridedSliceLayerInfo  info 
)
static

Adds a strided slice node to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the strided slice layer node as a NodeID-Index pair
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]infoContains masks for the starts, ends and strides
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 726 of file GraphBuilder.cpp.

727 {
728  return create_simple_single_input_output_node<StridedSliceLayerNode>(g, params, input, starts, ends, strides, info);
729 }

References arm_compute::test::validation::info, and arm_compute::test::validation::input.

Referenced by StridedSliceLayer::create_layer().

◆ add_yolo_node()

NodeID add_yolo_node ( Graph g,
NodeParams  params,
NodeIdxPair  input,
ActivationLayerInfo  act_info 
)
static

Adds a yolo layer to the graph.

Parameters
[in]gGraph to add the node to
[in]paramsCommon node parameters
[in]inputInput to the yolo layer node as a NodeID-Index pair
[in]act_infoActivation layer parameters
Returns
Node ID of the created node, EmptyNodeID in case of error

Definition at line 736 of file GraphBuilder.cpp.

737 {
738  check_nodeidx_pair(input, g);
739 
740  // Get input tensor descriptor
741  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
742  const bool is_nhwc = input_tensor_desc.layout == DataLayout::NHWC;
743 
744  // Box format: [Objectness:1][Box:4][Classes:N]
745 
746  // Activate objectness and front part of the box
747  const Coordinates box_start(0, 0, 0);
748  const Coordinates box_end = is_nhwc ? Coordinates(3, -1, -1) : Coordinates(-1, -1, 3);
749  NodeID box = g.add_node<SliceLayerNode>(box_start, box_end);
750  NodeID act_box = g.add_node<ActivationLayerNode>(act_info);
751  set_node_params(g, box, params);
752  set_node_params(g, act_box, params);
753  g.add_connection(input.node_id, input.index, box, 0);
754  g.add_connection(box, 0, act_box, 0);
755 
756  // Immutable part
757  const Coordinates imm_start = is_nhwc ? Coordinates(3, 0, 0) : Coordinates(0, 0, 3);
758  const Coordinates imm_end = is_nhwc ? Coordinates(5, -1, -1) : Coordinates(-1, -1, 5);
759  NodeID imm = g.add_node<SliceLayerNode>(imm_start, imm_end);
760  set_node_params(g, imm, params);
761  g.add_connection(input.node_id, input.index, imm, 0);
762 
763  // Activation classes and end part of box
764  const Coordinates cls_start = is_nhwc ? Coordinates(5, 0, 0) : Coordinates(0, 0, 5);
765  const Coordinates cls_end = Coordinates(-1, -1, -1);
766  NodeID cls = g.add_node<SliceLayerNode>(cls_start, cls_end);
767  NodeID cls_act = g.add_node<ActivationLayerNode>(act_info);
768  set_node_params(g, cls, params);
769  set_node_params(g, cls_act, params);
770  g.add_connection(input.node_id, input.index, cls, 0);
771  g.add_connection(cls, 0, cls_act, 0);
772 
773  NodeID concat = g.add_node<ConcatenateLayerNode>(3, descriptors::ConcatLayerDescriptor(DataLayoutDimension::CHANNEL));
774  set_node_params(g, concat, params);
775  g.add_connection(act_box, 0, concat, 0);
776  g.add_connection(imm, 0, concat, 1);
777  g.add_connection(cls_act, 0, concat, 2);
778 
779  return concat;
780 }

References arm_compute::test::validation::act_info, Graph::add_connection(), Graph::add_node(), arm_compute::CHANNEL, arm_compute::test::framework::dataset::concat(), arm_compute::graph::get_tensor_descriptor(), arm_compute::test::validation::input, TensorDescriptor::layout, arm_compute::NHWC, Graph::node(), and INode::outputs().

Referenced by YOLOLayer::create_layer().


The documentation for this class was generated from the following files:
arm_compute::graph::EltwiseOperation::Mul
@ Mul
Arithmetic multiplication.
arm_compute::DataLayout
DataLayout
[DataLayout enum definition]
Definition: CoreTypes.h:109
arm_compute::DataLayoutDimension::CHANNEL
@ CHANNEL
channel
arm_compute::DataLayout::NHWC
@ NHWC
Num samples, height, width, channels.
arm_compute::graph::FullyConnectedLayerNode::compute_weights_descriptor
static TensorDescriptor compute_weights_descriptor(const TensorDescriptor &input_descriptor, unsigned int num_outputs, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo &weights_quant_info=QuantizationInfo())
Computes weights descriptor.
Definition: FullyConnectedLayer.cpp:55
arm_compute::graph::get_dimension_size
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor's given dimension depending on its layout.
Definition: Utils.cpp:142
arm_compute::DataLayoutDimension::WIDTH
@ WIDTH
width
arm_compute::test::validation::act_info
act_info
Definition: DirectConvolutionLayer.cpp:547
arm_compute::test::validation::has_bias
const bool has_bias
Definition: Im2Col.cpp:152
arm_compute::test::validation::shape
shape
Definition: DFT.cpp:115
ARM_COMPUTE_ERROR_ON
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:467
arm_compute::DataLayoutDimension::HEIGHT
@ HEIGHT
height
arm_compute::test::framework::dataset::concat
JoinDataset< T, U > concat(T &&dataset1, U &&dataset2)
Helper function to create a JoinDataset.
Definition: JoinDataset.h:160
arm_compute::graph::GraphBuilder::add_elementwise_node
static NodeID add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation)
Adds an element-wise layer node to the graph.
Definition: GraphBuilder.cpp:449
arm_compute::graph::NodeID
unsigned int NodeID
Definition: Types.h:73
arm_compute::test::validation::num_groups
const unsigned int num_groups
Definition: Im2Col.cpp:153
arm_compute::graph::EltwiseOperation::Add
@ Add
Arithmetic addition.
arm_compute::graph::get_dimension_idx
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor's given dimension depending on its layout.
Definition: Utils.cpp:148
arm_compute::test::validation::conv_info
const auto conv_info
Definition: ConvolutionLayer.cpp:407
arm_compute::DataType::S32
@ S32
signed 32-bit number
arm_compute::is_data_type_quantized_asymmetric
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: DataTypeUtils.h:346
arm_compute::graph::get_tensor_descriptor
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
arm_compute::DataLayoutDimension::BATCHES
@ BATCHES
batches
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
arm_compute::graph::EmptyNodeID
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:80
arm_compute::test::validation::input
auto input
Definition: LSTMLayerQuantized.cpp:486
arm_compute::quantization::epsilon
constexpr float epsilon
Definition: AsymmHelpers.cpp:39