Compute Library
 21.11
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 136 of file GraphBuilder.cpp.

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

Referenced by ActivationLayer::create_layer().

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

◆ 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 142 of file GraphBuilder.cpp.

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

Referenced by ArgMinMaxLayer::create_layer().

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

◆ 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 148 of file GraphBuilder.cpp.

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(), NodeIdxPair::index, Graph::node(), NodeIdxPair::node_id, INode::outputs(), and TensorDescriptor::shape.

Referenced by BatchNormalizationLayer::create_layer().

151 {
152  check_nodeidx_pair(input, g);
153 
154  bool has_beta = (beta_accessor != nullptr);
155  bool has_gamma = (gamma_accessor != nullptr);
156 
157  // Get input tensor descriptor
158  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
159 
160  // Calculate Common Descriptor
161  TensorDescriptor common_desc = input_tensor_desc;
162  common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL));
163 
164  // Create mean and var nodes
165  auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor));
166  auto var_nid = add_const_node_with_name(g, params, "Variance", common_desc, std::move(var_accessor));
167 
168  // Create beta node
169  NodeID beta_nid = EmptyNodeID;
170  if(has_beta)
171  {
172  beta_nid = add_const_node_with_name(g, params, "Beta", common_desc, std::move(beta_accessor));
173  }
174 
175  // Create gamma node
176  NodeID gamma_nid = EmptyNodeID;
177  if(has_gamma)
178  {
179  gamma_nid = add_const_node_with_name(g, params, "Gamma", common_desc, std::move(gamma_accessor));
180  }
181 
182  // Create batch normalization node and add connections
183  NodeID batch_norm_nid = g.add_node<BatchNormalizationLayerNode>(epsilon);
184  g.add_connection(input.node_id, input.index, batch_norm_nid, 0);
185  g.add_connection(mean_nid, 0, batch_norm_nid, 1);
186  g.add_connection(var_nid, 0, batch_norm_nid, 2);
187  if(has_beta)
188  {
189  g.add_connection(beta_nid, 0, batch_norm_nid, 3);
190  }
191  if(has_gamma)
192  {
193  g.add_connection(gamma_nid, 0, batch_norm_nid, 4);
194  }
195  set_node_params(g, batch_norm_nid, params);
196 
197  return batch_norm_nid;
198 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76

◆ 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 200 of file GraphBuilder.cpp.

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

Referenced by BoundingBoxTransformLayer::create_layer().

201 {
202  check_nodeidx_pair(input, g);
203  check_nodeidx_pair(deltas, g);
204 
205  NodeID nid = g.add_node<BoundingBoxTransformLayerNode>(info);
206 
207  g.add_connection(input.node_id, input.index, nid, 0);
208  g.add_connection(deltas.node_id, deltas.index, nid, 1);
209 
210  set_node_params(g, nid, params);
211  return nid;
212 }
unsigned int NodeID
Definition: Types.h:69
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ 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 214 of file GraphBuilder.cpp.

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

Referenced by ChannelShuffleLayer::create_layer().

215 {
216  return create_simple_single_input_output_node<ChannelShuffleLayerNode>(g, params, input, num_groups);
217 }
const unsigned int num_groups
Definition: Im2Col.cpp:153

◆ 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 327 of file GraphBuilder.cpp.

Referenced by ConcatLayer::create_layer().

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

◆ 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 108 of file GraphBuilder.cpp.

References Graph::add_node().

Referenced by ConstantLayer::create_layer().

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

◆ 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 219 of file GraphBuilder.cpp.

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, NodeIdxPair::index, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), NodeIdxPair::node_id, 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().

225 {
226  check_nodeidx_pair(input, g);
227  ARM_COMPUTE_ERROR_ON(depth == 0);
228  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
229 
230  bool has_bias = (bias_accessor != nullptr);
231 
232  // Get input tensor descriptor
233  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
234  const DataLayout input_data_layout = input_tensor_desc.layout;
235 
236  // Create weights node
237  TensorDescriptor w_desc = input_tensor_desc;
238  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
239  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
240  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
242  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::BATCHES), depth);
243  if(!weights_quant_info.empty())
244  {
245  w_desc.quant_info = weights_quant_info;
246  }
247 
248  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
249 
250  // Create bias nodes
251  NodeID b_nid = EmptyNodeID;
252  if(has_bias)
253  {
254  TensorDescriptor b_desc = input_tensor_desc;
255  b_desc.shape = TensorShape(depth);
256  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
257  {
258  b_desc.data_type = DataType::S32;
259  }
260  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
261  }
262 
263  // Create convolution node and connect
264  NodeID conv_nid = g.add_node<ConvolutionLayerNode>(conv_info, num_groups, method, fast_math_hint, out_quant_info);
265  g.add_connection(input.node_id, input.index, conv_nid, 0);
266  g.add_connection(w_nid, 0, conv_nid, 1);
267  if(has_bias)
268  {
269  g.add_connection(b_nid, 0, conv_nid, 2);
270  }
271  set_node_params(g, conv_nid, params);
272 
273  return conv_nid;
274 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
1 channel, 1 S32 per channel
const unsigned int num_groups
Definition: Im2Col.cpp:153
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ 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 276 of file GraphBuilder.cpp.

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, NodeIdxPair::index, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), NodeIdxPair::node_id, INode::outputs(), arm_compute::S32, TensorShape::set(), TensorDescriptor::shape, Size2D::width, and arm_compute::WIDTH.

Referenced by DeconvolutionLayer::create_layer().

280 {
281  check_nodeidx_pair(input, g);
282  ARM_COMPUTE_ERROR_ON(depth == 0);
283  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
284 
285  bool has_bias = (bias_accessor != nullptr);
286 
287  // Get input tensor descriptor
288  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
289  const DataLayout input_data_layout = input_tensor_desc.layout;
290 
291  // Create weights node
292  TensorDescriptor w_desc = input_tensor_desc;
293  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
294  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
295  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
297  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::BATCHES), depth);
298 
299  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
300 
301  // Create bias nodes
302  NodeID b_nid = EmptyNodeID;
303  if(has_bias)
304  {
305  TensorDescriptor b_desc = input_tensor_desc;
306  b_desc.shape = TensorShape(depth);
307  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
308  {
309  b_desc.data_type = DataType::S32;
310  }
311  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
312  }
313 
314  // Create convolution node and connect
315  NodeID deconv_nid = g.add_node<DeconvolutionLayerNode>(descriptors::DeconvolutionLayerDescriptor{ deconv_info });
316  g.add_connection(input.node_id, input.index, deconv_nid, 0);
317  g.add_connection(w_nid, 0, deconv_nid, 1);
318  if(has_bias)
319  {
320  g.add_connection(b_nid, 0, deconv_nid, 2);
321  }
322  set_node_params(g, deconv_nid, params);
323 
324  return deconv_nid;
325 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
1 channel, 1 S32 per channel
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ 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 386 of file GraphBuilder.cpp.

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

Referenced by DepthToSpaceLayer::create_layer().

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

◆ 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 332 of file GraphBuilder.cpp.

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, NodeIdxPair::index, arm_compute::is_data_type_quantized_asymmetric(), TensorDescriptor::layout, Graph::node(), NodeIdxPair::node_id, INode::outputs(), TensorDescriptor::quant_info, arm_compute::S32, TensorShape::set(), TensorDescriptor::shape, Size2D::width, and arm_compute::WIDTH.

Referenced by DepthwiseConvolutionLayer::create_layer().

335 {
336  check_nodeidx_pair(input, g);
337  ARM_COMPUTE_ERROR_ON((kernel_spatial_extend.width == 0) || (kernel_spatial_extend.height == 0));
338 
339  bool has_bias = (bias_accessor != nullptr);
340 
341  // Get input tensor descriptor
342  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
343  const DataLayout input_data_layout = input_tensor_desc.layout;
344 
345  // Create weights node
346  TensorDescriptor w_desc = input_tensor_desc;
347  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), kernel_spatial_extend.width);
348  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), kernel_spatial_extend.height);
349  w_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL),
350  get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier);
351  if(!quant_info.empty())
352  {
353  w_desc.quant_info = quant_info;
354  }
355 
356  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
357 
358  // Create bias nodes
359  NodeID b_nid = EmptyNodeID;
360  if(has_bias)
361  {
362  TensorDescriptor b_desc = input_tensor_desc;
363  b_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL) * depth_multiplier);
364 
365  if(is_data_type_quantized_asymmetric(b_desc.data_type))
366  {
367  b_desc.data_type = DataType::S32;
368  }
369 
370  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
371  }
372 
373  // Create convolution node and connect
374  NodeID conv_nid = g.add_node<DepthwiseConvolutionLayerNode>(conv_info, depth_multiplier, method, out_quant_info);
375  g.add_connection(input.node_id, input.index, conv_nid, 0);
376  g.add_connection(w_nid, 0, conv_nid, 1);
377  if(has_bias)
378  {
379  g.add_connection(b_nid, 0, conv_nid, 2);
380  }
381  set_node_params(g, conv_nid, params);
382 
383  return conv_nid;
384 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
1 channel, 1 S32 per channel
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ 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 391 of file GraphBuilder.cpp.

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

Referenced by DequantizationLayer::create_layer().

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

◆ 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 396 of file GraphBuilder.cpp.

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

Referenced by DetectionOutputLayer::create_layer().

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

◆ 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 413 of file GraphBuilder.cpp.

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().

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

◆ 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 443 of file GraphBuilder.cpp.

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

Referenced by DummyLayer::create_layer().

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

◆ 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 448 of file GraphBuilder.cpp.

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

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

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

◆ 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 463 of file GraphBuilder.cpp.

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

Referenced by FlattenLayer::create_layer().

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

◆ add_fully_connected_layer() [1/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 468 of file GraphBuilder.cpp.

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, NodeIdxPair::index, Graph::node(), NodeIdxPair::node_id, and INode::outputs().

Referenced by FullyConnectedLayer::create_layer().

471 {
472  check_nodeidx_pair(input, g);
473  ARM_COMPUTE_ERROR_ON(num_outputs == 0);
474  ARM_COMPUTE_ERROR_ON(weights_nid == EmptyNodeID);
475 
476  const bool has_bias = (bias_nid != EmptyNodeID);
477 
478  // Get input tensor descriptor
479  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
480 
481  // Create fully connected node and connect
482  NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info, fast_math_hint);
483  g.add_connection(input.node_id, input.index, fc_nid, 0);
484  g.add_connection(weights_nid, 0, fc_nid, 1);
485  if(has_bias)
486  {
487  g.add_connection(bias_nid, 0, fc_nid, 2);
488  }
489 
490  set_node_params(g, fc_nid, params);
491 
492  return fc_nid;
493 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76

◆ add_fully_connected_layer() [2/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 495 of file GraphBuilder.cpp.

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, NodeIdxPair::index, arm_compute::is_data_type_quantized_asymmetric(), Graph::node(), NodeIdxPair::node_id, INode::outputs(), arm_compute::S32, and TensorDescriptor::shape.

499 {
500  check_nodeidx_pair(input, g);
501  ARM_COMPUTE_ERROR_ON(num_outputs == 0);
502 
503  bool has_bias = (bias_accessor != nullptr);
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  // Create weights node
509  TensorDescriptor w_desc = FullyConnectedLayerNode::compute_weights_descriptor(input_tensor_desc, num_outputs, fc_info, weights_quant_info);
510  NodeID w_nid = add_const_node_with_name(g, params, "Weights", w_desc, std::move(weights_accessor));
511 
512  // Create bias nodes
513  NodeID b_nid = EmptyNodeID;
514  if(has_bias)
515  {
516  TensorDescriptor b_desc = input_tensor_desc;
517  b_desc.shape = TensorShape(num_outputs);
518  if(is_data_type_quantized_asymmetric(input_tensor_desc.data_type))
519  {
520  b_desc.data_type = DataType::S32;
521  }
522  b_nid = add_const_node_with_name(g, params, "Bias", b_desc, std::move(bias_accessor));
523  }
524 
525  // Create fully connected node and connect
526  NodeID fc_nid = g.add_node<FullyConnectedLayerNode>(num_outputs, out_quant_info, fc_info, fast_math_hint);
527  g.add_connection(input.node_id, input.index, fc_nid, 0);
528  g.add_connection(w_nid, 0, fc_nid, 1);
529  if(has_bias)
530  {
531  g.add_connection(b_nid, 0, fc_nid, 2);
532  }
533 
534  set_node_params(g, fc_nid, params);
535 
536  return fc_nid;
537 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
1 channel, 1 S32 per channel
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
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.

◆ 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 539 of file GraphBuilder.cpp.

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

Referenced by GenerateProposalsLayer::create_layer().

540 {
541  check_nodeidx_pair(scores, g);
542  check_nodeidx_pair(deltas, g);
543  check_nodeidx_pair(anchors, g);
544 
545  NodeID nid = g.add_node<GenerateProposalsLayerNode>(info);
546 
547  g.add_connection(scores.node_id, scores.index, nid, 0);
548  g.add_connection(deltas.node_id, deltas.index, nid, 1);
549  g.add_connection(anchors.node_id, anchors.index, nid, 2);
550 
551  set_node_params(g, nid, params);
552  return nid;
553 }
unsigned int NodeID
Definition: Types.h:69
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ 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 116 of file GraphBuilder.cpp.

References Graph::add_node().

Referenced by InputLayer::create_layer().

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

◆ 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 555 of file GraphBuilder.cpp.

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

Referenced by L2NormalizeLayer::create_layer().

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

◆ 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 560 of file GraphBuilder.cpp.

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

Referenced by NormalizationLayer::create_layer().

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

◆ 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 565 of file GraphBuilder.cpp.

References Graph::add_connection(), Graph::add_node(), arm_compute::CHANNEL, arm_compute::graph::get_dimension_size(), arm_compute::graph::get_tensor_descriptor(), NodeIdxPair::index, Graph::node(), NodeIdxPair::node_id, INode::outputs(), and TensorDescriptor::shape.

Referenced by NormalizePlanarYUVLayer::create_layer().

567 {
568  check_nodeidx_pair(input, g);
569 
570  // Get input tensor descriptor
571  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
572 
573  // Calculate Common Descriptor
574  TensorDescriptor common_desc = input_tensor_desc;
575  common_desc.shape = TensorShape(get_dimension_size(input_tensor_desc, DataLayoutDimension::CHANNEL));
576 
577  // Create mean and std nodes
578  auto mean_nid = add_const_node_with_name(g, params, "Mean", common_desc, std::move(mean_accessor));
579  auto std_nid = add_const_node_with_name(g, params, "Std", common_desc, std::move(std_accessor));
580 
581  // Create normalize planar YUV node and add connections
582  NodeID norm_planar_yuv_nid = g.add_node<NormalizePlanarYUVLayerNode>();
583  g.add_connection(input.node_id, input.index, norm_planar_yuv_nid, 0);
584  g.add_connection(mean_nid, 0, norm_planar_yuv_nid, 1);
585  g.add_connection(std_nid, 0, norm_planar_yuv_nid, 2);
586  set_node_params(g, norm_planar_yuv_nid, params);
587 
588  return norm_planar_yuv_nid;
589 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
Get size of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:142
unsigned int NodeID
Definition: Types.h:69

◆ 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 124 of file GraphBuilder.cpp.

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

Referenced by OutputLayer::create_layer().

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

◆ 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 591 of file GraphBuilder.cpp.

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

Referenced by PadLayer::create_layer().

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

◆ 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 596 of file GraphBuilder.cpp.

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

Referenced by PermuteLayer::create_layer().

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

◆ 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 615 of file GraphBuilder.cpp.

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

Referenced by PoolingLayer::create_layer().

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

◆ 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 601 of file GraphBuilder.cpp.

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

Referenced by PReluLayer::create_layer().

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

◆ 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 620 of file GraphBuilder.cpp.

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

Referenced by PrintLayer::create_layer().

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

◆ 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 625 of file GraphBuilder.cpp.

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

Referenced by PriorBoxLayer::create_layer().

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

◆ 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 640 of file GraphBuilder.cpp.

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

Referenced by QuantizationLayer::create_layer().

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

◆ 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 645 of file GraphBuilder.cpp.

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

Referenced by ReductionLayer::create_layer().

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

◆ 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 650 of file GraphBuilder.cpp.

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

Referenced by ReorgLayer::create_layer().

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

◆ 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 655 of file GraphBuilder.cpp.

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

Referenced by ReshapeLayer::create_layer().

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

◆ 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 660 of file GraphBuilder.cpp.

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

Referenced by ResizeLayer::create_layer().

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

◆ 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 666 of file GraphBuilder.cpp.

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

Referenced by ROIAlignLayer::create_layer().

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

◆ 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 680 of file GraphBuilder.cpp.

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, TensorDescriptor::layout, arm_compute::graph::Mul, Graph::node(), NodeIdxPair::node_id, INode::outputs(), TensorShape::set(), TensorDescriptor::shape, and arm_compute::WIDTH.

Referenced by ScaleLayer::create_layer().

681 {
682  check_nodeidx_pair(input, g);
683 
684  // Get input tensor descriptor
685  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
686  const DataLayout input_data_layout = input_tensor_desc.layout;
687 
688  // Create mul node
689  TensorDescriptor mul_desc = input_tensor_desc;
690  const size_t C = input_tensor_desc.shape[get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL)];
691  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), 1);
692  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), 1);
693  mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL), C);
694  NodeID mul_const_nid = add_const_node_with_name(g, params, "Mul", mul_desc, std::move(mul_accessor));
695  NodeIdxPair mul_const_nidxp = { mul_const_nid, 0 };
696 
697  // Create add node
698  TensorDescriptor add_desc = mul_desc;
699  NodeID add_const_nid = add_const_node_with_name(g, params, "Add", add_desc, std::move(add_accessor));
700  NodeIdxPair add_const_nidxp = { add_const_nid, 0 };
701 
702  // Create node and connect
703  NodeID mul_node = GraphBuilder::add_elementwise_node(g, params, input, mul_const_nidxp, EltwiseOperation::Mul);
704  NodeIdxPair mulnode_nidxp = { mul_node, 0 };
705  NodeID add_node = GraphBuilder::add_elementwise_node(g, params, mulnode_nidxp, add_const_nidxp, EltwiseOperation::Add);
706 
707  return add_node;
708 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
static NodeID add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation)
Adds an element-wise layer node to the graph.
unsigned int NodeID
Definition: Types.h:69
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ 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 715 of file GraphBuilder.cpp.

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

Referenced by SliceLayer::create_layer().

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

◆ 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 710 of file GraphBuilder.cpp.

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

Referenced by SoftmaxLayer::create_layer().

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

◆ 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 720 of file GraphBuilder.cpp.

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

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

◆ 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 730 of file GraphBuilder.cpp.

Referenced by StackLayer::create_layer().

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

◆ 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 725 of file GraphBuilder.cpp.

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

Referenced by StridedSliceLayer::create_layer().

726 {
727  return create_simple_single_input_output_node<StridedSliceLayerNode>(g, params, input, starts, ends, strides, info);
728 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ 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 735 of file GraphBuilder.cpp.

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

Referenced by YOLOLayer::create_layer().

736 {
737  check_nodeidx_pair(input, g);
738 
739  // Get input tensor descriptor
740  const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]);
741  const bool is_nhwc = input_tensor_desc.layout == DataLayout::NHWC;
742 
743  // Box format: [Objectness:1][Box:4][Classes:N]
744 
745  // Activate objectness and front part of the box
746  const Coordinates box_start(0, 0, 0);
747  const Coordinates box_end = is_nhwc ? Coordinates(3, -1, -1) : Coordinates(-1, -1, 3);
748  NodeID box = g.add_node<SliceLayerNode>(box_start, box_end);
749  NodeID act_box = g.add_node<ActivationLayerNode>(act_info);
750  set_node_params(g, box, params);
751  set_node_params(g, act_box, params);
752  g.add_connection(input.node_id, input.index, box, 0);
753  g.add_connection(box, 0, act_box, 0);
754 
755  // Immutable part
756  const Coordinates imm_start = is_nhwc ? Coordinates(3, 0, 0) : Coordinates(0, 0, 3);
757  const Coordinates imm_end = is_nhwc ? Coordinates(5, -1, -1) : Coordinates(-1, -1, 5);
758  NodeID imm = g.add_node<SliceLayerNode>(imm_start, imm_end);
759  set_node_params(g, imm, params);
760  g.add_connection(input.node_id, input.index, imm, 0);
761 
762  // Activation classes and end part of box
763  const Coordinates cls_start = is_nhwc ? Coordinates(5, 0, 0) : Coordinates(0, 0, 5);
764  const Coordinates cls_end = Coordinates(-1, -1, -1);
765  NodeID cls = g.add_node<SliceLayerNode>(cls_start, cls_end);
766  NodeID cls_act = g.add_node<ActivationLayerNode>(act_info);
767  set_node_params(g, cls, params);
768  set_node_params(g, cls_act, params);
769  g.add_connection(input.node_id, input.index, cls, 0);
770  g.add_connection(cls, 0, cls_act, 0);
771 
772  NodeID concat = g.add_node<ConcatenateLayerNode>(3, descriptors::ConcatLayerDescriptor(DataLayoutDimension::CHANNEL));
773  set_node_params(g, concat, params);
774  g.add_connection(act_box, 0, concat, 0);
775  g.add_connection(imm, 0, concat, 1);
776  g.add_connection(cls_act, 0, concat, 2);
777 
778  return concat;
779 }
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
Definition: Utils.h:50
unsigned int NodeID
Definition: Types.h:69
Num samples, height, width, channels.
JoinDataset< T, U > concat(T &&dataset1, U &&dataset2)
Helper function to create a JoinDataset.
Definition: JoinDataset.h:160

The documentation for this class was generated from the following files: