Compute Library
 20.02.1
arm_compute::misc::shape_calculator Namespace Reference

Functions

TensorShape calculate_reduce_mean_shape (ITensor *input, const Coordinates &reduction_axis, bool keep_dims)
 Calculate the output tensor shape for the reduce mean operation. More...
 
TensorShape compute_vector_to_tensor_output_shape (const TensorShape &input, size_t conv_w, size_t conv_h, const DataLayout &data_layout)
 Calculate the output tensor shape of a vector input given the convolution dimensions. More...
 
TensorShape compute_permutation_output_shape (const ITensorInfo &input, const PermutationVector &perm)
 Calculate the permuted shape of an input given a permutation vector. More...
 
TensorShape compute_reorg_output_shape (const ITensorInfo &input, int32_t stride)
 Calculate the output shape of the reorg layer given a stride. More...
 
TensorShape compute_weights_reshaped_shape (const ITensorInfo &weights, bool has_bias=false, unsigned int num_groups=1)
 Calculate the reshaped shape of the weights. More...
 
TensorShape compute_lhs_reshaped_shape (const ITensorInfo &a, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_input_as_3d=false)
 Calculate the Left Hand Side matrix reshaped shape. More...
 
TensorShape compute_rhs_reshaped_shape (const ITensorInfo &a, const GEMMRHSMatrixInfo &rhs_info)
 Calculate the Right Hand Side matrix reshaped shape. More...
 
TensorShape compute_interleaved_shape (const ITensorInfo &a, int mult_interleave4x4_height=1, bool reinterpret_input_as_3d=false)
 Calculate the interleaved shape of an input tensor. More...
 
TensorShape compute_reshaped_depthwise_weights_shape (const ITensorInfo &input, const DepthwiseConvolutionReshapeInfo &info)
 Calculate the reshaped shape of the weights to use in depthwise convolution. More...
 
TensorShape compute_transpose1xW_shape (const ITensorInfo &b)
 Calculate the transposed 1xW shape. More...
 
TensorShape compute_transpose1xW_with_element_size_shape (const ITensorInfo &b, int mult_transpose1xW_width=1)
 Calculate the transposed 1xW width element shape. More...
 
TensorShape compute_reductionA_shape (const ITensorInfo &b)
 Calculate the reductionA shape used in GEMMLowp. More...
 
TensorShape compute_reductionB_shape (const ITensorInfo &a)
 Calculate the reductionB shape used in GEMMLowp. More...
 
TensorShape compute_col2im_shape (const ITensorInfo &input, const Size2D &convolved_dims, bool batch_size_on_z, unsigned int num_groups=1)
 Calculate the Col2Im shape. More...
 
TensorShape compute_transposed_shape (const ITensorInfo &input)
 Calculate the transposed shape of a tensor. More...
 
TensorShape compute_depthwise_convolution_shape (const ITensorInfo &input, const ITensorInfo &weights, PadStrideInfo conv_info, unsigned int depth_multiplier, const Size2D &dilation=Size2D(1U, 1U))
 Calculate the depthwise convolution output shape of a tensor. More...
 
TensorShape compute_deconvolution_upsampled_shape (const ITensorInfo &input, const ITensorInfo &weights, unsigned int sx, unsigned int sy, std::pair< unsigned int, unsigned int > &out_dims, unsigned int &padx, unsigned int &pady)
 Calculate the upsampled output shape used for deconvolution. More...
 
TensorShape compute_deconvolution_output_shape (const std::pair< unsigned int, unsigned int > &out_dims, const ITensorInfo &input, const ITensorInfo &weights)
 Calculate the output shape of the deconvolution layer. More...
 
TensorShape compute_im2col_conv_shape (const ITensorInfo *input, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation, bool batch_size_on_z, unsigned int num_groups=1)
 Calculate the im2col output shape of a tensor. More...
 
TensorShape compute_flatten_shape (const ITensorInfo *input)
 Calculate the flattened output shape of a tensor. More...
 
TensorShape compute_softmax_shape (const ITensorInfo *input, size_t axis=1)
 Calculate the softmax output shape of a tensor. More...
 
TensorShape compute_winograd_filter_transform_shape (const ITensorInfo &input, const WinogradInfo &winograd_info)
 Calculate the winograd filter transform shape. More...
 
TensorShape compute_winograd_input_transform_shape (const ITensorInfo &input, const WinogradInfo &winograd_info)
 Calculate the winograd input transform shape. More...
 
TensorShape compute_winograd_output_transform_shape (const ITensorInfo &input, const WinogradInfo &winograd_info)
 Calculate the winograd output transform shape. More...
 
TensorShape compute_deep_convolution_shape (const ITensorInfo &input, const ITensorInfo &weights, PadStrideInfo conv_info)
 Calculate the deep convolution shape output shape of a tensor. More...
 
TensorShape compute_min_max_shape (const ITensorInfo *input)
 Calculate the min/max shape output shape of a tensor. More...
 
TensorShape compute_pool_shape (const ITensorInfo &input, PoolingLayerInfo pool_info)
 Calculate the output pool shape of a tensor. More...
 
TensorShape compute_roi_align_shape (const ITensorInfo &input, const ITensorInfo &rois, ROIPoolingLayerInfo pool_info)
 Calculate the output roi align shape of a tensor. More...
 
TensorShape compute_rnn_shape (const ITensorInfo *input, const unsigned int batch_size)
 Calculate the RNN shape of a tensor. More...
 
TensorShape compute_mm_shape (const ITensorInfo &input0, const ITensorInfo &input1, bool is_interleaved_transposed, const GEMMReshapeInfo &reshape_info)
 Calculate the matrix multiplication output shape of two tensors. More...
 
TensorShape compute_mm_shape (const ITensorInfo &input0, const ITensorInfo &input1, const GEMMReshapeInfo &gemm_info)
 Calculate the matrix multiplication output shape of two tensors. More...
 
TensorShape compute_mm_shape (const ITensorInfo &input0, const ITensorInfo &input1, const GEMMKernelInfo &gemm_info)
 Calculate the matrix multiplication output shape of two tensors. More...
 
TensorShape compute_output_stage_shape (const ITensorInfo &input, unsigned int gemm_3d_depth=1, bool batch_size_on_z=false)
 Calculate the matrix multiplication output shape of two tensors. More...
 
TensorShape compute_strided_slice_shape (const ITensorInfo &input, const Coordinates &starts, const Coordinates &ends, const Coordinates &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
 Calculate the strided slice output shape of a tensor. More...
 
TensorShape compute_slice_shape (const TensorShape &input_shape, const Coordinates &starts, const Coordinates &ends)
 Calculate the slice output shape of a tensor. More...
 
TensorShape compute_batch_to_space_shape (const ITensorInfo *input, const int block_x, const int block_y)
 Calculate the batch to space output shape of a tensor. More...
 
TensorShape compute_depth_to_space_shape (const ITensorInfo *input, int block)
 Calculate the depth to space output shape of a tensor. More...
 
TensorShape compute_split_shape (const ITensorInfo *input, unsigned int axis, unsigned int num_splits)
 Calculate the split output shape of a tensor. More...
 
TensorShape compute_space_to_batch_shape (const ITensorInfo *input, const int block_x, const int block_y, const Size2D &padding_left, const Size2D &padding_right)
 Calculate the space to batch output shape of a tensor. More...
 
TensorShape compute_space_to_depth_shape (const ITensorInfo *input, int32_t block_shape)
 Calculate the space to batch output shape of a tensor. More...
 
TensorShape compute_prior_box_shape (const ITensorInfo &input, const PriorBoxLayerInfo &info)
 Calculate the prior box output shape of a tensor. More...
 
TensorShape compute_padded_shape (const TensorShape &input_shape, const PaddingList &padding)
 Calculate the padded shape of a tensor. More...
 
TensorShape compute_tiled_shape (const TensorShape &input_shape, const Multiples &multiples)
 Calculate the tiled shape of a tensor. More...
 
TensorShape compute_reduced_shape (const TensorShape &input, unsigned int axis, bool keep_dims=true)
 Calculate the reduced shape of a tensor given an axis. More...
 
TensorShape compute_upsample_shape (const ITensorInfo &input, const Size2D &info)
 Calculate the upsampled shape of a tensor. More...
 
template<typename T >
TensorShape extract_shape (T *data)
 Get the tensor shape. More...
 
TensorShape extract_shape (ITensorInfo *data)
 
TensorShape extract_shape (const ITensorInfo *data)
 
TensorShape extract_shape (const TensorShape *data)
 
TensorShape extract_shape (TensorShape *data)
 
TensorShape calculate_unstack_shape (TensorShape input_shape, unsigned int axis)
 Calculate the unstack shape of a tensor. More...
 
template<typename T >
TensorShape calculate_concatenate_shape (const std::vector< T * > &input, size_t axis)
 Calculate the concatenate output shape of the concatenate operation along a single axis. More...
 
TensorShape compute_stack_shape (const ITensorInfo &a, unsigned int axis, unsigned int num_tensors)
 Calculate the stack output shape of a tensor. More...
 
TensorShape compute_gather_shape (const TensorShape &input_shape, const TensorShape &indices_shape, uint32_t actual_axis)
 

Function Documentation

◆ calculate_concatenate_shape()

TensorShape arm_compute::misc::shape_calculator::calculate_concatenate_shape ( const std::vector< T * > &  input,
size_t  axis 
)
inline

Calculate the concatenate output shape of the concatenate operation along a single axis.

Parameters
[in]inputVector containing the shapes of the inputs
[in]axisAxis along which to concatenate the input tensors
Returns
the calculated shape

Definition at line 1315 of file ShapeCalculator.h.

1316 {
1317  TensorShape out_shape = extract_shape(input[0]);
1318 
1319 #if defined(ARM_COMPUTE_ASSERTS_ENABLED)
1320  // All dimensions must match except the axis one
1321  for(unsigned int i = 0; i < MAX_DIMS; ++i)
1322  {
1323  if(i == axis)
1324  {
1325  continue;
1326  }
1327 
1328  for(const auto &tensor : input)
1329  {
1330  ARM_COMPUTE_ERROR_ON(tensor == nullptr);
1331  const TensorShape shape = extract_shape(tensor);
1332  ARM_COMPUTE_ERROR_ON(out_shape[i] != shape[i]);
1333  }
1334  }
1335 #endif // defined(ARM_COMPUTE_ASSERTS_ENABLED)
1336 
1337  // Calculate output shape
1338  size_t new_size = 0;
1339  for(const auto &tensor : input)
1340  {
1341  const TensorShape shape = extract_shape(tensor);
1342  new_size += shape[axis];
1343  }
1344 
1345  out_shape.set(axis, new_size);
1346 
1347  return out_shape;
1348 }
#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
constexpr size_t MAX_DIMS
Constant value used to indicate maximum dimensions of a Window, TensorShape and Coordinates.
Definition: Dimensions.h:37
TensorShape extract_shape(TensorShape *data)

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::axis, extract_shape(), arm_compute::test::validation::input, arm_compute::MAX_DIMS, TensorShape::set(), and arm_compute::test::validation::shape.

Referenced by ConcatenateLayerNode::compute_output_descriptor(), GCConcatenateLayer::configure(), CLLSTMLayer::configure(), NELSTMLayer::validate(), and CLLSTMLayer::validate().

◆ calculate_reduce_mean_shape()

TensorShape arm_compute::misc::shape_calculator::calculate_reduce_mean_shape ( ITensor input,
const Coordinates reduction_axis,
bool  keep_dims 
)
inline

Calculate the output tensor shape for the reduce mean operation.

Parameters
[in]inputInput tensor shape
[in]reduction_axisReduction axis
[in]keep_dimsFlag to indicate if dimensions are kept
Returns
the calculated shape

Definition at line 50 of file ShapeCalculator.h.

51 {
52  const int reduction_ops = reduction_axis.num_dimensions();
53  Coordinates axis_local = reduction_axis;
54  const int input_dims = input->info()->num_dimensions();
55  convert_negative_axis(axis_local, input_dims);
56  TensorShape out_shape = input->info()->tensor_shape();
57  // Configure reshape layer if we want to drop the dimensions
58  if(!keep_dims)
59  {
60  // We have to sort the reduction axis vectors in order for remove_dimension
61  // to work properly
62  std::sort(axis_local.begin(), axis_local.begin() + reduction_ops);
63  for(int i = 0; i < reduction_ops; ++i)
64  {
65  out_shape.remove_dimension(axis_local[i] - i);
66  }
67  return out_shape;
68  }
69  else
70  {
71  for(int i = 0; i < reduction_ops; ++i)
72  {
73  out_shape.set(axis_local[i], 1);
74  }
75  return out_shape;
76  }
77 }
Coordinates & convert_negative_axis(Coordinates &coords, int max_value)
Convert negative coordinates to positive in the range [0, num_dims_input].
Definition: Helpers.h:774

References Dimensions< T >::begin(), arm_compute::convert_negative_axis(), arm_compute::test::validation::input, Dimensions< T >::num_dimensions(), TensorShape::remove_dimension(), and TensorShape::set().

Referenced by CLReduceMean::configure(), and NEReduceMean::configure().

◆ calculate_unstack_shape()

TensorShape arm_compute::misc::shape_calculator::calculate_unstack_shape ( TensorShape  input_shape,
unsigned int  axis 
)
inline

Calculate the unstack shape of a tensor.

Parameters
[in]input_shapeInput tensor shape
[in]axisAxis on which to perform the unstack operation
Returns
the calculated shape

Definition at line 1300 of file ShapeCalculator.h.

1301 {
1302  ARM_COMPUTE_ERROR_ON(axis > input_shape.num_dimensions());
1303  input_shape.remove_dimension(axis);
1304  return input_shape;
1305 }
#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

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::axis, and arm_compute::test::validation::input_shape.

◆ compute_batch_to_space_shape()

TensorShape arm_compute::misc::shape_calculator::compute_batch_to_space_shape ( const ITensorInfo input,
const int  block_x,
const int  block_y 
)
inline

Calculate the batch to space output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]block_xBlock shape x value
[in]block_yBlock shape y value
Returns
the calculated shape

Definition at line 1036 of file ShapeCalculator.h.

1037 {
1038  ARM_COMPUTE_ERROR_ON(block_x <= 0 || block_y <= 0);
1039 
1040  const DataLayout data_layout = input->data_layout();
1041  const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1042  const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1043  const int idx_batch = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
1044 
1045  TensorShape output_shape{ input->tensor_shape() };
1046  output_shape.set(idx_width, input->tensor_shape()[idx_width] * block_x);
1047  output_shape.set(idx_height, input->tensor_shape()[idx_height] * block_y);
1048  output_shape.set(idx_batch, input->tensor_shape()[idx_batch] / (block_x * block_y));
1049 
1050  return output_shape;
1051 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
#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
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References ARM_COMPUTE_ERROR_ON, arm_compute::BATCHES, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

Referenced by CLBatchToSpaceLayerKernel::configure(), and NEBatchToSpaceLayerKernel::configure().

◆ compute_col2im_shape()

TensorShape arm_compute::misc::shape_calculator::compute_col2im_shape ( const ITensorInfo input,
const Size2D convolved_dims,
bool  batch_size_on_z,
unsigned int  num_groups = 1 
)
inline

Calculate the Col2Im shape.

Parameters
[in]inputInput tensor info
[in]convolved_dimsConvolved dimensions
[in]batch_size_on_zTrue if batch size is on z axis
[in]num_groups(Optional) Number of groups when performing a grouped convolution
Returns
the calculated shape

Definition at line 395 of file ShapeCalculator.h.

396 {
398  ARM_COMPUTE_ERROR_ON(input.tensor_shape()[1] != (convolved_dims.area()));
399  ARM_COMPUTE_ERROR_ON((num_groups > 1) && input.tensor_shape()[2] != num_groups);
400 
401  const DataLayout data_layout = input.data_layout();
402  const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
403  const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
404  const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
405 
406  TensorShape col2im_shape{ input.tensor_shape() };
407  // If batches start on 3rd dimension shift dimensions right by 1 to retain upper tensor shape,
408  // as first three will be override by H,W,C data
409  if(batch_size_on_z && num_groups == 1)
410  {
411  col2im_shape.shift_right(1);
412  }
413  col2im_shape.set(width_idx, convolved_dims.width);
414  col2im_shape.set(height_idx, convolved_dims.height);
415  col2im_shape.set(channel_idx, input.tensor_shape()[0] * num_groups);
416 
417  return col2im_shape;
418 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
#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
const unsigned int num_groups
Definition: Im2Col.cpp:148
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References Size2D::area(), ARM_COMPUTE_ERROR_ON, arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::num_groups, Size2D::width, and arm_compute::WIDTH.

◆ compute_deconvolution_output_shape()

TensorShape arm_compute::misc::shape_calculator::compute_deconvolution_output_shape ( const std::pair< unsigned int, unsigned int > &  out_dims,
const ITensorInfo input,
const ITensorInfo weights 
)
inline

Calculate the output shape of the deconvolution layer.

Parameters
[in]out_dimsOutput x and y shape dimensions
[in]inputInput tensor info
[in]weightsWeights tensor shape
Returns
the calculated shape

Definition at line 519 of file ShapeCalculator.h.

520 {
521  const TensorShape input_shape{ input.tensor_shape() };
522  const TensorShape weights_shape{ weights.tensor_shape() };
523 
524  const DataLayout data_layout = input.data_layout();
525  const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
526  const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
527  const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
528  const int batch_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
529 
530  TensorShape out_shape{ input_shape };
531  out_shape.set(width_idx, out_dims.first);
532  out_shape.set(height_idx, out_dims.second);
533  out_shape.set(channel_idx, weights_shape[batch_idx]);
534  return out_shape;
535 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::BATCHES, arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::input_shape, arm_compute::test::validation::weights, arm_compute::test::validation::weights_shape, and arm_compute::WIDTH.

Referenced by CLDirectDeconvolutionLayer::configure(), NEDeconvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), NEDeconvolutionLayer::validate(), CLDirectDeconvolutionLayer::validate(), and CLGEMMDeconvolutionLayer::validate().

◆ compute_deconvolution_upsampled_shape()

TensorShape arm_compute::misc::shape_calculator::compute_deconvolution_upsampled_shape ( const ITensorInfo input,
const ITensorInfo weights,
unsigned int  sx,
unsigned int  sy,
std::pair< unsigned int, unsigned int > &  out_dims,
unsigned int &  padx,
unsigned int &  pady 
)
inline

Calculate the upsampled output shape used for deconvolution.

Parameters
[in]inputInput tensor info
[in]weightsWeights tensor shape
[in]sxStride on x axis
[in]syStride on y axis
[in]out_dimsOutput shape dimensions
[in]padxPadding on x axis
[in]padyPadding on y axis
Returns
the calculated shape

Definition at line 487 of file ShapeCalculator.h.

489 {
490  const DataLayout data_layout = input.data_layout();
491  const size_t idx_w = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
492  const size_t idx_h = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
493 
494  // Find the upsampled dimensions
495  unsigned int out_x = (input.dimension(idx_w) - 1) * sx + 1;
496  unsigned int out_y = (input.dimension(idx_h) - 1) * sy + 1;
497 
498  // Find the padding needed for the convolution with stride 1 in order to match output shape
499  padx = out_dims.first - (out_x - weights.dimension(idx_w) + 1);
500  pady = out_dims.second - (out_y - weights.dimension(idx_h) + 1);
501  out_x += padx;
502  out_y += pady;
503 
504  TensorShape scale_out_shape(input.tensor_shape());
505  scale_out_shape.set(idx_w, out_x);
506  scale_out_shape.set(idx_h, out_y);
507 
508  return scale_out_shape;
509 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, TensorShape::set(), arm_compute::test::validation::weights, and arm_compute::WIDTH.

Referenced by CLDirectDeconvolutionLayer::configure(), NEDeconvolutionLayer::configure(), NEDeconvolutionLayer::validate(), and CLDirectDeconvolutionLayer::validate().

◆ compute_deep_convolution_shape()

TensorShape arm_compute::misc::shape_calculator::compute_deep_convolution_shape ( const ITensorInfo input,
const ITensorInfo weights,
PadStrideInfo  conv_info 
)
inline

Calculate the deep convolution shape output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]weightsWeights tensor info
[in]conv_infoContains padding and stride information
Returns
the calculated shape

Definition at line 738 of file ShapeCalculator.h.

739 {
740  const TensorShape input_shape{ input.tensor_shape() };
741  const TensorShape weights_shape{ weights.tensor_shape() };
742 
743  const size_t idx_width = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH);
744  const size_t idx_height = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT);
745  const size_t idx_channel = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::CHANNEL);
746 
747  const unsigned int input_width = input_shape[idx_width];
748  const unsigned int input_height = input_shape[idx_height];
749  const unsigned int weights_width = weights_shape[idx_width];
750  const unsigned int weights_height = weights_shape[idx_height];
751  const unsigned int weights_out_channel = weights_shape[3];
752  unsigned int output_width = 0;
753  unsigned int output_height = 0;
754  std::tie(output_width, output_height) = scaled_dimensions(input_width, input_height, weights_width, weights_height, conv_info);
755 
756  TensorShape output_shape{ input_shape };
757  output_shape.set(idx_width, output_width);
758  output_shape.set(idx_height, output_height);
759  output_shape.set(idx_channel, weights_out_channel);
760 
761  return output_shape;
762 }
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References arm_compute::CHANNEL, arm_compute::test::validation::conv_info, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::input_shape, arm_compute::test::validation::output_shape, arm_compute::scaled_dimensions(), arm_compute::test::validation::weights, arm_compute::test::validation::weights_shape, and arm_compute::WIDTH.

Referenced by NEDirectConvolutionLayerKernel::configure(), and CLDirectConvolutionLayerKernel::configure().

◆ compute_depth_to_space_shape()

TensorShape arm_compute::misc::shape_calculator::compute_depth_to_space_shape ( const ITensorInfo input,
int  block 
)
inline

Calculate the depth to space output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]blockBlock shape value
Returns
the calculated shape

Definition at line 1060 of file ShapeCalculator.h.

1061 {
1062  ARM_COMPUTE_ERROR_ON(block < 2);
1063 
1064  const DataLayout data_layout = input->data_layout();
1065  const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1066  const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1067  const int idx_channel = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
1068 
1069  TensorShape output_shape{ input->tensor_shape() };
1070  output_shape.set(idx_width, input->dimension(idx_width) * block);
1071  output_shape.set(idx_height, input->dimension(idx_height) * block);
1072  output_shape.set(idx_channel, input->dimension(idx_channel) / (block * block));
1073 
1074  return output_shape;
1075 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
#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
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References ARM_COMPUTE_ERROR_ON, arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

Referenced by CLDepthToSpaceLayerKernel::configure(), CLSpaceToDepthLayerKernel::configure(), and NEDepthToSpaceLayerKernel::configure().

◆ compute_depthwise_convolution_shape()

TensorShape arm_compute::misc::shape_calculator::compute_depthwise_convolution_shape ( const ITensorInfo input,
const ITensorInfo weights,
PadStrideInfo  conv_info,
unsigned int  depth_multiplier,
const Size2D dilation = Size2D(1U,                                                       1U) 
)
inline

Calculate the depthwise convolution output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]weightsWeights tensor info
[in]conv_infoPadding and stride information to use for the convolution.
[in]depth_multiplierMultiplier to apply to the input's depth in order to retrieve the output's depth.
[in]dilationDilation, in elements, across x and y. Defaults to (1, 1).
Returns
the calculated shape

Definition at line 446 of file ShapeCalculator.h.

448 {
449  const TensorShape input_shape{ input.tensor_shape() };
450  const TensorShape weights_shape{ weights.tensor_shape() };
451 
452  const DataLayout data_layout = input.data_layout();
453  const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
454  const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
455  const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
456 
457  const DataLayout weights_data_layout = weights.data_layout();
458  const int weights_width_idx = get_data_layout_dimension_index(weights_data_layout, DataLayoutDimension::WIDTH);
459  const int weights_height_idx = get_data_layout_dimension_index(weights_data_layout, DataLayoutDimension::HEIGHT);
460 
461  unsigned int output_width = 0;
462  unsigned int output_height = 0;
463  std::tie(output_width, output_height) = scaled_dimensions(input_shape[width_idx], input_shape[height_idx],
464  weights_shape[weights_width_idx], weights_shape[weights_height_idx],
466 
467  TensorShape output_shape{ input_shape };
468  output_shape.set(width_idx, output_width);
469  output_shape.set(height_idx, output_height);
470  output_shape.set(channel_idx, input_shape[channel_idx] * depth_multiplier);
471 
472  return output_shape;
473 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::CHANNEL, arm_compute::test::validation::conv_info, arm_compute::test::validation::data_layout, arm_compute::test::validation::dilation, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::input_shape, arm_compute::test::validation::output_shape, arm_compute::scaled_dimensions(), arm_compute::test::validation::weights, arm_compute::test::validation::weights_shape, and arm_compute::WIDTH.

Referenced by GCDepthwiseConvolutionLayer3x3Kernel::configure(), NEDepthwiseConvolutionAssemblyDispatch::configure(), and NEDepthwiseConvolutionAssemblyDispatch::validate().

◆ compute_flatten_shape()

TensorShape arm_compute::misc::shape_calculator::compute_flatten_shape ( const ITensorInfo input)
inline

Calculate the flattened output shape of a tensor.

Parameters
[in]inputInput tensor info
Returns
the calculated shape

Definition at line 587 of file ShapeCalculator.h.

588 {
589  // The output shape will be the flatten version of the input (i.e. [ width * height * channels, num_batches, ... ] ). Used for FlattenLayer and FullyConnectedLayer.
590 
591  TensorShape output_shape{ input->tensor_shape() };
592 
593  output_shape.collapse(3);
594 
595  return output_shape;
596 }

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

Referenced by NEFullyConnectedLayer::validate(), and CLFullyConnectedLayer::validate().

◆ compute_gather_shape()

TensorShape arm_compute::misc::shape_calculator::compute_gather_shape ( const TensorShape input_shape,
const TensorShape indices_shape,
uint32_t  actual_axis 
)
inline

Definition at line 1379 of file ShapeCalculator.h.

1380 {
1381  ARM_COMPUTE_ERROR_ON(indices_shape.num_dimensions() > 1);
1382  ARM_COMPUTE_ERROR_ON(input_shape.num_dimensions() > 4);
1383  ARM_COMPUTE_ERROR_ON(actual_axis >= input_shape.num_dimensions());
1384 
1385  TensorShape output_shape = input_shape;
1386  output_shape[actual_axis] = indices_shape[0];
1387 
1388  return output_shape;
1389 }
#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

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::input_shape, Dimensions< T >::num_dimensions(), and arm_compute::test::validation::output_shape.

Referenced by NEGatherKernel::configure(), and arm_compute::test::validation::reference::gather().

◆ compute_im2col_conv_shape()

TensorShape arm_compute::misc::shape_calculator::compute_im2col_conv_shape ( const ITensorInfo input,
const Size2D kernel_dims,
const PadStrideInfo conv_info,
bool  has_bias,
const Size2D dilation,
bool  batch_size_on_z,
unsigned int  num_groups = 1 
)
inline

Calculate the im2col output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]kernel_dimsThe kernel dimensions (width and height).
[in]conv_infoContains padding and stride information
[in]has_biasIn case biases are provided expands the matrix with 1
[in]dilationDilation, in elements, across x and y
[in]batch_size_on_zTrue if batch size is on z axis
[in]num_groups(Optional) Number of groups when performing a grouped convolution
Returns
the calculated shape

Definition at line 549 of file ShapeCalculator.h.

551 {
552  // The output shape will be the 3D shape [ out_channels * kernel_area, num_elems_per_out_channel, batches ] if batch_size_on_z == true
553  // or the 4D shape [ out_channels * kernel_area / num_groups, num_elems_per_out_channel, num_groups, batches ] if batch_size_on_z == false
554 
556  ARM_COMPUTE_ERROR_ON(num_groups > 1 && input->data_layout() != DataLayout::NCHW);
557  ARM_COMPUTE_ERROR_ON(num_groups > 1 && batch_size_on_z);
558 
559  TensorShape output_shape{ input->tensor_shape() };
560 
561  const DataLayout data_layout = input->data_layout();
562  const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
563  const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
564  const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
565 
566  std::pair<unsigned int, unsigned int> out_dims = scaled_dimensions(output_shape[width_idx], output_shape[height_idx], kernel_dims.width, kernel_dims.height, conv_info, dilation);
567  output_shape.set(0, (output_shape[channel_idx] / num_groups * kernel_dims.area() + (has_bias ? 1 : 0))); // NOLINT
568  output_shape.set(1, (out_dims.first * out_dims.second));
569  if(batch_size_on_z && output_shape.num_dimensions() >= 3)
570  {
571  output_shape.remove_dimension(2);
572  }
573  else
574  {
575  output_shape.set(2, num_groups);
576  }
577 
578  return output_shape;
579 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
#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
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
const unsigned int num_groups
Definition: Im2Col.cpp:148
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References Size2D::area(), ARM_COMPUTE_ERROR_ON, arm_compute::CHANNEL, arm_compute::test::validation::conv_info, arm_compute::test::validation::data_layout, arm_compute::test::validation::dilation, arm_compute::get_data_layout_dimension_index(), arm_compute::test::validation::has_bias, Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::NCHW, arm_compute::test::validation::num_groups, arm_compute::test::validation::output_shape, arm_compute::scaled_dimensions(), Size2D::width, and arm_compute::WIDTH.

Referenced by CLGEMMConvolutionLayer::validate().

◆ compute_interleaved_shape()

TensorShape arm_compute::misc::shape_calculator::compute_interleaved_shape ( const ITensorInfo a,
int  mult_interleave4x4_height = 1,
bool  reinterpret_input_as_3d = false 
)
inline

Calculate the interleaved shape of an input tensor.

Parameters
[in]aInput tensor info
[in]mult_interleave4x4_height(Optional) Interleave4x4 height
[in]reinterpret_input_as_3d(Optional) Set to true if the input need to be interpreted as 3d
Returns
the calculated shape

Definition at line 260 of file ShapeCalculator.h.

261 {
262  // The interleaved output matrix will have the following shape: [ a_height * W, ceil(a_width / W) ] where W = 4 * mult_interleave4x4_height
263  ARM_COMPUTE_ERROR_ON(mult_interleave4x4_height < 1);
264  const int interleave_width = 4 * mult_interleave4x4_height;
265  TensorShape shape_interleaved_a{ a.tensor_shape() };
266  shape_interleaved_a.set(0, a.dimension(0) * interleave_width);
267  if(reinterpret_input_as_3d)
268  {
269  const int M = a.dimension(1) * a.dimension(2);
270  const int height = std::ceil(M / static_cast<float>(interleave_width));
271  shape_interleaved_a.set(1, height);
272 
273  // When the data format is NHWC and the shapes are Nx1x1
274  // the tensor shape num_dimensions is automatically set to 1 instead of 3.
275  // To avoid failures by removing a dimension that doesn't exist
276  // check if the number of dimensions is greater than 2.
277  if(shape_interleaved_a.num_dimensions() > 2)
278  {
279  shape_interleaved_a.remove_dimension(2);
280  }
281  }
282  else
283  {
284  shape_interleaved_a.set(1, std::ceil(a.dimension(1) / static_cast<float>(interleave_width)));
285  }
286 
287  return shape_interleaved_a;
288 }
#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

References ARM_COMPUTE_ERROR_ON, ITensorInfo::dimension(), TensorShape::set(), and ITensorInfo::tensor_shape().

Referenced by NEGEMMInterleave4x4Kernel::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), and NEGEMM::validate().

◆ compute_lhs_reshaped_shape()

TensorShape arm_compute::misc::shape_calculator::compute_lhs_reshaped_shape ( const ITensorInfo a,
const GEMMLHSMatrixInfo lhs_info,
bool  reinterpret_input_as_3d = false 
)
inline

Calculate the Left Hand Side matrix reshaped shape.

Parameters
[in]aInput tensor info
[in]lhs_infoLeft Hand Side matrix information
[in]reinterpret_input_as_3d(Optional) Set to true if the input need to be interpreted as 3d
Returns
the calculated shape

Definition at line 180 of file ShapeCalculator.h.

181 {
182  ARM_COMPUTE_ERROR_ON(lhs_info.m0 == 0);
183  ARM_COMPUTE_ERROR_ON(lhs_info.k0 == 0);
184  ARM_COMPUTE_ERROR_ON(lhs_info.v0 == 0);
185 
186  // Input width/height
187  const unsigned int input_width = a.dimension(0);
188  const unsigned int input_height = reinterpret_input_as_3d ? a.dimension(1) * a.dimension(2) : a.dimension(1);
189 
190  // Number of horizontal/vertical blocks in the input tensor
191  const unsigned int num_horiz_blocks = std::ceil(input_width / static_cast<float>(lhs_info.k0));
192  const unsigned int num_vert_blocks = std::ceil(input_height / static_cast<float>(lhs_info.m0));
193 
194  // Block size
195  const unsigned int block_size = lhs_info.m0 * lhs_info.k0;
196 
197  // Output width/height
198  const unsigned int output_width = block_size * num_horiz_blocks * lhs_info.v0;
199  const unsigned int output_height = std::ceil(num_vert_blocks / static_cast<float>(lhs_info.v0));
200 
201  TensorShape lhs_shape{ a.tensor_shape() };
202  lhs_shape.set(0, output_width);
203  lhs_shape.set(1, output_height);
204 
205  if((reinterpret_input_as_3d) && (lhs_shape.num_dimensions() > 2))
206  {
207  // When the data format is NHWC and the shapes are Nx1x1
208  // the tensor shape num_dimensions is automatically set to 1 instead of 3.
209  // To avoid failures by removing a dimension that doesn't exist
210  // check if the number of dimensions is greater than 2.
211  lhs_shape.remove_dimension(2);
212  }
213 
214  return lhs_shape;
215 }
#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

References ARM_COMPUTE_ERROR_ON, ITensorInfo::dimension(), GEMMLHSMatrixInfo::k0, GEMMLHSMatrixInfo::m0, TensorShape::remove_dimension(), TensorShape::set(), ITensorInfo::tensor_shape(), and GEMMLHSMatrixInfo::v0.

◆ compute_min_max_shape()

TensorShape arm_compute::misc::shape_calculator::compute_min_max_shape ( const ITensorInfo input)
inline

Calculate the min/max shape output shape of a tensor.

Parameters
[in]inputInput tensor info
Returns
the calculated shape

Definition at line 770 of file ShapeCalculator.h.

771 {
772  TensorShape output_shape{ input->tensor_shape() };
773  output_shape.set(Window::DimX, 2);
774  output_shape.remove_dimension(1);
775  output_shape.remove_dimension(1);
776 
777  return output_shape;
778 }

References Window::DimX, arm_compute::test::validation::input, and arm_compute::test::validation::output_shape.

◆ compute_mm_shape() [1/3]

TensorShape arm_compute::misc::shape_calculator::compute_mm_shape ( const ITensorInfo input0,
const ITensorInfo input1,
bool  is_interleaved_transposed,
const GEMMReshapeInfo reshape_info 
)
inline

Calculate the matrix multiplication output shape of two tensors.

Parameters
[in]input0First input tensor info
[in]input1Second input tensor info
[in]is_interleaved_transposedTrue if the input is interleaved transposed
[in]reshape_infoGEMM reshape info
Returns
the calculated shape

Definition at line 858 of file ShapeCalculator.h.

859 {
860  ARM_COMPUTE_ERROR_ON_MSG(input0.num_dimensions() > 4, "The number of dimensions for the matrix A must be <= 4");
861  ARM_COMPUTE_ERROR_ON_MSG(is_interleaved_transposed && reshape_info.reinterpret_input_as_3d(), "The first input tensor cannot be reinterpreted as 3D if is_interleaved_transposed is true");
862 
863  const bool reinterpret_input_as_3d = reshape_info.reinterpret_input_as_3d();
864  const bool reinterpret_output_as_3d = reshape_info.depth_output_gemm3d() != 0;
865  const int depth_output_gemm3d = reinterpret_output_as_3d ? reshape_info.depth_output_gemm3d() : 1;
866  const int m = reshape_info.reinterpret_input_as_3d() ? input0.dimension(1) * input0.dimension(2) : input0.dimension(1);
867 
868  // If the output of GEMM has to be reinterpreted as 3D, the number of input0 rows (M) is obtained collapsing the second and third
869  // dimension of the output tensor
870  const int dim0 = is_interleaved_transposed ? reshape_info.n() : input1.dimension(0);
871  const int dim1 = is_interleaved_transposed ? reshape_info.m() / depth_output_gemm3d : m / depth_output_gemm3d;
872  const int dim2 = reinterpret_input_as_3d ? input0.tensor_shape()[3] : input0.tensor_shape()[2];
873  const int dim3 = reinterpret_input_as_3d ? 1 : input0.tensor_shape()[3];
874 
875  TensorShape output_shape{ input0.tensor_shape() };
876 
877  output_shape.set(0, dim0);
878  output_shape.set(1, dim1);
879  output_shape.set(2, reinterpret_output_as_3d ? depth_output_gemm3d : dim2);
880  output_shape.set(3, reinterpret_output_as_3d ? dim2 : dim3);
881  output_shape.set(4, reinterpret_output_as_3d ? dim3 : 1);
882 
883  return output_shape;
884 }
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456

References ARM_COMPUTE_ERROR_ON_MSG, GEMMReshapeInfo::depth_output_gemm3d(), ITensorInfo::dimension(), GEMMReshapeInfo::m(), GEMMReshapeInfo::n(), ITensorInfo::num_dimensions(), arm_compute::test::validation::output_shape, GEMMReshapeInfo::reinterpret_input_as_3d(), and ITensorInfo::tensor_shape().

Referenced by CLGEMMLowpMatrixMultiplyCore::validate(), and NEGEMM::validate().

◆ compute_mm_shape() [2/3]

TensorShape arm_compute::misc::shape_calculator::compute_mm_shape ( const ITensorInfo input0,
const ITensorInfo input1,
const GEMMReshapeInfo gemm_info 
)
inline

Calculate the matrix multiplication output shape of two tensors.

Note
Deprecated. Remove when GEMMReshapeInfo is not used anymore by any other kernels
Parameters
[in]input0First input tensor info
[in]input1Second input tensor info
[in]gemm_infoGEMM reshape info
Returns
the calculated shape

Definition at line 896 of file ShapeCalculator.h.

897 {
898  ARM_COMPUTE_UNUSED(input1);
899  ARM_COMPUTE_ERROR_ON_MSG(input0.num_dimensions() > 4, "The number of dimensions for the matrix A must be <= 4");
900 
901  const bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d();
902  const bool reinterpret_output_as_3d = gemm_info.depth_output_gemm3d() != 0;
903  const int depth_output_gemm3d = reinterpret_output_as_3d ? gemm_info.depth_output_gemm3d() : 1;
904 
905  TensorShape output_shape{ input0.tensor_shape() };
906 
907  if(!reinterpret_input_as_3d && !reinterpret_output_as_3d)
908  {
909  output_shape.set(0, gemm_info.n());
910  output_shape.set(1, gemm_info.m());
911  }
912  else
913  {
914  // If the output of GEMM has to be reinterpreted as 3D, the number of input0 rows (M) is obtained collapsing the second and third
915  // dimension of the output tensor
916  const int batch_size = reinterpret_input_as_3d ? input0.tensor_shape()[3] : input0.tensor_shape()[2];
917  output_shape.set(0, gemm_info.n());
918  output_shape.set(1, gemm_info.m() / depth_output_gemm3d);
919  output_shape.set(2, reinterpret_output_as_3d ? depth_output_gemm3d : batch_size);
920  output_shape.set(3, reinterpret_output_as_3d ? batch_size : 1);
921  }
922 
923  return output_shape;
924 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456

References ARM_COMPUTE_ERROR_ON_MSG, ARM_COMPUTE_UNUSED, GEMMReshapeInfo::depth_output_gemm3d(), GEMMReshapeInfo::m(), GEMMReshapeInfo::n(), ITensorInfo::num_dimensions(), arm_compute::test::validation::output_shape, GEMMReshapeInfo::reinterpret_input_as_3d(), and ITensorInfo::tensor_shape().

◆ compute_mm_shape() [3/3]

TensorShape arm_compute::misc::shape_calculator::compute_mm_shape ( const ITensorInfo input0,
const ITensorInfo input1,
const GEMMKernelInfo gemm_info 
)
inline

Calculate the matrix multiplication output shape of two tensors.

Parameters
[in]input0First input tensor info
[in]input1Second input tensor info
[in]gemm_infoGEMM kernel info used to retrieve the original dimensions of the input matrices
Returns
the calculated shape

Definition at line 934 of file ShapeCalculator.h.

935 {
936  ARM_COMPUTE_UNUSED(input1);
937  ARM_COMPUTE_ERROR_ON_MSG(input0.num_dimensions() > 4, "The number of dimensions for the matrix A must be <= 4");
938 
939  const bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d;
940  const bool reinterpret_output_as_3d = gemm_info.depth_output_gemm3d != 0;
941  const unsigned int depth_output_gemm3d = reinterpret_output_as_3d ? gemm_info.depth_output_gemm3d : 1;
942 
943  TensorShape output_shape{ input0.tensor_shape() };
944 
945  if(!reinterpret_input_as_3d && !reinterpret_output_as_3d)
946  {
947  output_shape.set(0, gemm_info.n);
948  output_shape.set(1, gemm_info.m);
949  }
950  else
951  {
952  // If the output of GEMM has to be reinterpreted as 3D, the number of input0 rows (M) is obtained collapsing the second and third
953  // dimension of the output tensor
954  const unsigned int batch_size = reinterpret_input_as_3d ? input0.tensor_shape()[3] : input0.tensor_shape()[2];
955  output_shape.set(0, gemm_info.n);
956  output_shape.set(1, gemm_info.m / depth_output_gemm3d);
957  output_shape.set(2, reinterpret_output_as_3d ? depth_output_gemm3d : batch_size);
958  output_shape.set(3, reinterpret_output_as_3d ? batch_size : 1);
959  }
960 
961  return output_shape;
962 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456

References ARM_COMPUTE_ERROR_ON_MSG, ARM_COMPUTE_UNUSED, GEMMKernelInfo::depth_output_gemm3d, GEMMKernelInfo::m, GEMMKernelInfo::n, ITensorInfo::num_dimensions(), arm_compute::test::validation::output_shape, GEMMKernelInfo::reinterpret_input_as_3d, and ITensorInfo::tensor_shape().

◆ compute_output_stage_shape()

TensorShape arm_compute::misc::shape_calculator::compute_output_stage_shape ( const ITensorInfo input,
unsigned int  gemm_3d_depth = 1,
bool  batch_size_on_z = false 
)
inline

Calculate the matrix multiplication output shape of two tensors.

Parameters
[in]inputInput tensor info
[in]gemm_3d_depth(Optional) GEMM 3d depth
[in]batch_size_on_z(Optional) True if batch size is on z axis
Returns
the calculated shape

Definition at line 972 of file ShapeCalculator.h.

973 {
974  ARM_COMPUTE_ERROR_ON(input.data_layout() != DataLayout::NHWC && gemm_3d_depth > 1);
975 
976  TensorShape output_shape = input.tensor_shape();
977  if(gemm_3d_depth > 1)
978  {
979  if(batch_size_on_z)
980  {
981  output_shape.shift_right(1);
982  }
983  output_shape.set(0, input.tensor_shape().x());
984  output_shape.set(1, input.tensor_shape().y() / gemm_3d_depth);
985  output_shape.set(2, gemm_3d_depth);
986  }
987 
988  return output_shape;
989 }
#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

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::input, arm_compute::NHWC, and arm_compute::test::validation::output_shape.

◆ compute_padded_shape()

TensorShape arm_compute::misc::shape_calculator::compute_padded_shape ( const TensorShape input_shape,
const PaddingList padding 
)
inline

Calculate the padded shape of a tensor.

Parameters
[in]input_shapeInput tensor shape
[in]paddingPaddings list
Returns
the calculated shape

Definition at line 1187 of file ShapeCalculator.h.

1188 {
1189  TensorShape padded_shape = input_shape;
1190  for(size_t dim = 0; dim < padding.size(); ++dim)
1191  {
1192  const auto &padding_pair = padding[dim];
1193  const uint32_t shape_on_index = (padded_shape.num_dimensions() <= dim) ? 1 : input_shape[dim];
1194  padded_shape.set(dim, padding_pair.first + shape_on_index + padding_pair.second);
1195  }
1196  return padded_shape;
1197 }

References arm_compute::test::validation::input_shape, Dimensions< T >::num_dimensions(), arm_compute::test::validation::padding, and TensorShape::set().

Referenced by NEPadLayer::configure(), NEPadLayerKernel::configure(), arm_compute::test::validation::reference::pad_layer(), and NEPadLayer::validate().

◆ compute_permutation_output_shape()

TensorShape arm_compute::misc::shape_calculator::compute_permutation_output_shape ( const ITensorInfo input,
const PermutationVector perm 
)
inline

Calculate the permuted shape of an input given a permutation vector.

Parameters
[in]inputInput tensor info
[in]permPermutation vector
Returns
the calculated shape

Definition at line 108 of file ShapeCalculator.h.

109 {
110  TensorShape output_shape = input.tensor_shape();
111  permute(output_shape, perm);
112  return output_shape;
113 }
void permute(Dimensions< T > &dimensions, const PermutationVector &perm)
Permutes given Dimensions according to a permutation vector.
Definition: Helpers.h:570

References arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::permute().

Referenced by CPPPermuteKernel::configure(), and NEPermuteKernel::configure().

◆ compute_pool_shape()

TensorShape arm_compute::misc::shape_calculator::compute_pool_shape ( const ITensorInfo input,
PoolingLayerInfo  pool_info 
)
inline

Calculate the output pool shape of a tensor.

Parameters
[in]inputInput tensor info
[in]pool_infoPooling layer info
Returns
the calculated shape

Definition at line 787 of file ShapeCalculator.h.

788 {
789  unsigned int pooled_w = 0;
790  unsigned int pooled_h = 0;
791 
792  TensorShape output_shape{ input.tensor_shape() };
793 
794  const bool is_global_pooling = pool_info.is_global_pooling;
795  const unsigned int idx_width = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH);
796  const unsigned int idx_height = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT);
797  const unsigned int pool_size_x = is_global_pooling ? output_shape[idx_width] : pool_info.pool_size.width;
798  const unsigned int pool_size_y = is_global_pooling ? output_shape[idx_height] : pool_info.pool_size.height;
799 
800  std::tie(pooled_w, pooled_h) = scaled_dimensions(output_shape[idx_width],
801  output_shape[idx_height],
802  pool_size_x,
803  pool_size_y,
804  pool_info.pad_stride_info);
805 
806  output_shape.set(idx_width, pooled_w);
807  output_shape.set(idx_height, pooled_h);
808 
809  return output_shape;
810 }
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, PoolingLayerInfo::is_global_pooling, arm_compute::test::validation::output_shape, PoolingLayerInfo::pad_stride_info, PoolingLayerInfo::pool_size, arm_compute::scaled_dimensions(), Size2D::width, and arm_compute::WIDTH.

Referenced by arm_compute::test::validation::reference::pooling_layer_internal().

◆ compute_prior_box_shape()

TensorShape arm_compute::misc::shape_calculator::compute_prior_box_shape ( const ITensorInfo input,
const PriorBoxLayerInfo info 
)
inline

Calculate the prior box output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]infoPriorBoxLayer info
Returns
the calculated shape

Definition at line 1166 of file ShapeCalculator.h.

1167 {
1168  DataLayout data_layout = input.data_layout();
1169  const size_t idx_w = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1170  const size_t idx_h = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1171  const int num_priors = info.aspect_ratios().size() * info.min_sizes().size() + info.max_sizes().size();
1172 
1173  TensorShape output_shape{};
1174  output_shape.set(0, input.dimension(idx_w) * input.dimension(idx_h) * num_priors * 4);
1175  output_shape.set(1, 2);
1176 
1177  return output_shape;
1178 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::info, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

◆ compute_reduced_shape()

TensorShape arm_compute::misc::shape_calculator::compute_reduced_shape ( const TensorShape input,
unsigned int  axis,
bool  keep_dims = true 
)
inline

Calculate the reduced shape of a tensor given an axis.

Parameters
[in]inputInput tensor info
[in]axisAxis on which to perform reduction
[in]keep_dims(Optional) Whether to keep the dimension after reduction operation. Defaults to true.
Returns
the calculated shape

Definition at line 1224 of file ShapeCalculator.h.

1225 {
1226  TensorShape output_shape{ input };
1227 
1228  if(!keep_dims)
1229  {
1230  output_shape.remove_dimension(axis);
1231  }
1232  else
1233  {
1234  output_shape.set(axis, 1);
1235  }
1236 
1237  return output_shape;
1238 }

References arm_compute::test::validation::axis, arm_compute::test::validation::input, and arm_compute::test::validation::output_shape.

Referenced by NEReductionOperation::configure(), CLReductionOperation::configure(), CLArgMinMaxLayer::configure(), NEReductionOperation::validate(), CLArgMinMaxLayer::validate(), and CLReductionOperation::validate().

◆ compute_reductionA_shape()

TensorShape arm_compute::misc::shape_calculator::compute_reductionA_shape ( const ITensorInfo b)
inline

Calculate the reductionA shape used in GEMMLowp.

Parameters
[in]bInput tensor info
Returns
the calculated shape

Definition at line 357 of file ShapeCalculator.h.

358 {
359  TensorShape shape_vector_sum_col{ b.tensor_shape() };
360  if(shape_vector_sum_col.num_dimensions() > 1)
361  {
362  shape_vector_sum_col.remove_dimension(1);
363  }
364 
365  return shape_vector_sum_col;
366 }
SimpleTensor< float > b
Definition: DFT.cpp:157

References arm_compute::test::validation::b.

Referenced by CLGEMMLowpMatrixMultiplyCore::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), CLGEMMLowpMatrixMultiplyCore::validate(), and NEGEMMLowpMatrixMultiplyCore::validate().

◆ compute_reductionB_shape()

TensorShape arm_compute::misc::shape_calculator::compute_reductionB_shape ( const ITensorInfo a)
inline

Calculate the reductionB shape used in GEMMLowp.

Parameters
[in]aInput tensor info
Returns
the calculated shape

Definition at line 374 of file ShapeCalculator.h.

375 {
376  TensorShape shape_vector_sum_row{ a.tensor_shape() };
377  shape_vector_sum_row.set(Window::DimX, a.dimension(1));
378  if(shape_vector_sum_row.num_dimensions() > 1)
379  {
380  shape_vector_sum_row.remove_dimension(1);
381  }
382 
383  return shape_vector_sum_row;
384 }

References ITensorInfo::dimension(), Window::DimX, TensorShape::remove_dimension(), TensorShape::set(), and ITensorInfo::tensor_shape().

Referenced by CLGEMMLowpMatrixMultiplyCore::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), CLGEMMLowpMatrixMultiplyCore::validate(), and NEGEMMLowpMatrixMultiplyCore::validate().

◆ compute_reorg_output_shape()

TensorShape arm_compute::misc::shape_calculator::compute_reorg_output_shape ( const ITensorInfo input,
int32_t  stride 
)
inline

Calculate the output shape of the reorg layer given a stride.

Parameters
[in]inputInput tensor info
[in]strideStride
Returns
the calculated shape

Definition at line 122 of file ShapeCalculator.h.

123 {
124  const size_t idx_width = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH);
125  const size_t idx_height = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT);
126  const size_t idx_channel = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::CHANNEL);
127 
128  ARM_COMPUTE_ERROR_ON(stride <= 0);
129  ARM_COMPUTE_ERROR_ON_MSG((input.tensor_shape()[idx_width] % stride != 0), "The width of the input tensor must be a multiple of stride");
130  ARM_COMPUTE_ERROR_ON_MSG((input.tensor_shape()[idx_height] % stride != 0), "The height of the input tensor must be a multiple of stride");
131 
132  TensorShape output_shape{ input.tensor_shape() };
133 
134  output_shape.set(idx_width, output_shape[idx_width] / stride);
135  output_shape.set(idx_height, output_shape[idx_height] / stride);
136  output_shape.set(idx_channel, output_shape[idx_channel] * stride * stride);
137 
138  return output_shape;
139 }
#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
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_MSG, arm_compute::CHANNEL, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

Referenced by CLReorgLayerKernel::configure(), NEReorgLayerKernel::configure(), and arm_compute::test::validation::reference::reorg_layer().

◆ compute_reshaped_depthwise_weights_shape()

TensorShape arm_compute::misc::shape_calculator::compute_reshaped_depthwise_weights_shape ( const ITensorInfo input,
const DepthwiseConvolutionReshapeInfo info 
)
inline

Calculate the reshaped shape of the weights to use in depthwise convolution.

Parameters
[in]inputInput tensor info
[in]infoDepthwise convolution information to be used for reshaping.
Returns
the calculated shape

Definition at line 297 of file ShapeCalculator.h.

298 {
299  const auto data_layout = input.data_layout();
300  TensorShape weights_shape{};
301 
302  const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
303  const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
304  const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
305  const size_t num_channels = input.dimension(channel_idx);
306  const size_t num_rows = input.dimension(height_idx);
307  const size_t num_cols = input.dimension(width_idx);
308 
309  weights_shape.set(0, num_rows * num_cols * info.c0);
310  weights_shape.set(1, DIV_CEIL(num_channels, info.c0));
311  return weights_shape;
312 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
constexpr auto DIV_CEIL(S val, T m) -> decltype((val+m - 1)/m)
Calculate the rounded up quotient of val / m.
Definition: Utils.h:53
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::DIV_CEIL(), arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::info, arm_compute::test::validation::input, arm_compute::test::validation::weights_shape, and arm_compute::WIDTH.

◆ compute_rhs_reshaped_shape()

TensorShape arm_compute::misc::shape_calculator::compute_rhs_reshaped_shape ( const ITensorInfo a,
const GEMMRHSMatrixInfo rhs_info 
)
inline

Calculate the Right Hand Side matrix reshaped shape.

Parameters
[in]aInput tensor info
[in]rhs_infoRight Hand Side matrix information
Returns
the calculated shape

Definition at line 224 of file ShapeCalculator.h.

225 {
226  ARM_COMPUTE_ERROR_ON(rhs_info.n0 == 0);
227  ARM_COMPUTE_ERROR_ON(rhs_info.k0 == 0);
228  ARM_COMPUTE_ERROR_ON(rhs_info.h0 == 0);
229 
230  // Input width/height
231  const unsigned int input_width = a.dimension(0);
232  const unsigned int input_height = a.dimension(1);
233 
234  // Number of horizontal/vertical blocks in the input tensor
235  const unsigned int num_horiz_blocks = std::ceil(input_width / static_cast<float>(rhs_info.n0));
236  const unsigned int num_vert_blocks = std::ceil(input_height / static_cast<float>(rhs_info.k0));
237 
238  // Block size
239  const unsigned int block_size = rhs_info.n0 * rhs_info.k0;
240 
241  // Output width/height
242  const unsigned int output_width = block_size * num_vert_blocks * rhs_info.h0;
243  const unsigned int output_height = std::ceil(num_horiz_blocks / static_cast<float>(rhs_info.h0));
244 
245  TensorShape rhs_shape{ a.tensor_shape() };
246  rhs_shape.set(0, output_width);
247  rhs_shape.set(1, output_height);
248 
249  return rhs_shape;
250 }
#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

References ARM_COMPUTE_ERROR_ON, ITensorInfo::dimension(), GEMMRHSMatrixInfo::h0, GEMMRHSMatrixInfo::k0, GEMMRHSMatrixInfo::n0, TensorShape::set(), and ITensorInfo::tensor_shape().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and CLGEMMLowpMatrixMultiplyCore::validate().

◆ compute_rnn_shape()

TensorShape arm_compute::misc::shape_calculator::compute_rnn_shape ( const ITensorInfo input,
const unsigned int  batch_size 
)
inline

Calculate the RNN shape of a tensor.

Parameters
[in]inputInput tensor info
[in]batch_sizeBatch size
Returns
the calculated shape

Definition at line 841 of file ShapeCalculator.h.

842 {
843  TensorShape output_shape{ input->tensor_shape() };
844  output_shape.set(1, batch_size);
845 
846  return output_shape;
847 }

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

Referenced by CLRNNLayer::configure(), NERNNLayer::configure(), CLRNNLayer::validate(), and NERNNLayer::validate().

◆ compute_roi_align_shape()

TensorShape arm_compute::misc::shape_calculator::compute_roi_align_shape ( const ITensorInfo input,
const ITensorInfo rois,
ROIPoolingLayerInfo  pool_info 
)
inline

Calculate the output roi align shape of a tensor.

Parameters
[in]inputInput tensor info
[in]roisRois tensor info
[in]pool_infoPooling layer info
Returns
the calculated shape

Definition at line 820 of file ShapeCalculator.h.

821 {
822  TensorShape output_shape{ input.tensor_shape() };
823 
824  const unsigned int idx_width = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH);
825  const unsigned int idx_height = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT);
826 
827  output_shape.set(idx_width, pool_info.pooled_width());
828  output_shape.set(idx_height, pool_info.pooled_height());
829  output_shape.set(3, rois.dimension(1));
830 
831  return output_shape;
832 }
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References ITensorInfo::dimension(), arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, ROIPoolingLayerInfo::pooled_height(), ROIPoolingLayerInfo::pooled_width(), and arm_compute::WIDTH.

◆ compute_slice_shape()

TensorShape arm_compute::misc::shape_calculator::compute_slice_shape ( const TensorShape input_shape,
const Coordinates starts,
const Coordinates ends 
)
inline

Calculate the slice output shape of a tensor.

Parameters
[in]input_shapeInput tensor info
[in]startsThe starts of the dimensions of the input tensor to be sliced
[in]endsThe ends of the dimensions of the input tensor to be sliced
Returns
the calculated shape

Definition at line 1019 of file ShapeCalculator.h.

1020 {
1022 
1024  starts, ends, BiStrides(),
1025  0, construct_slice_end_mask(ends), 0);
1026 }
Coordinates BiStrides
Bidirectional strides.
Definition: Types.h:50
int32_t construct_slice_end_mask(Coordinates ends)
Constructs end mask in case we want to perform a slice operation using the strided slice interface.
TensorShape compute_strided_slice_output_shape(TensorShape input_shape, Coordinates starts, Coordinates ends, Coordinates strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0, bool return_unshrinked=false)
Computes output shape of strided slice.

References arm_compute::helpers::tensor_transform::compute_strided_slice_output_shape(), arm_compute::helpers::tensor_transform::construct_slice_end_mask(), and arm_compute::test::validation::input_shape.

Referenced by SliceLayerNode::compute_output_descriptor(), and arm_compute::test::validation::reference::slice().

◆ compute_softmax_shape()

TensorShape arm_compute::misc::shape_calculator::compute_softmax_shape ( const ITensorInfo input,
size_t  axis = 1 
)
inline

Calculate the softmax output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]axis(Optional) Softmax axis
Returns
the calculated shape

Definition at line 605 of file ShapeCalculator.h.

606 {
607  // The output shape will be a 2D version of the input. For instance:
608  // - [x,y,z] and axis 1 will return [x, y*z]
609  // - [x,y,z,w] and axis 2 will return [x*y, w*z]
610  // - [x,y,z,w] and axis 3 will return [x*y*z, w]
611  TensorShape shape2D = input->tensor_shape();
612 
613  if(axis < input->num_dimensions())
614  {
615  // Collapse from axis onward (this changes the shape)
616  shape2D.collapse_from(axis);
617 
618  // Collapse the rest (collapse is inclusive)
619  shape2D.collapse(shape2D.num_dimensions() - 1);
620  }
621  else
622  {
623  // Collapse everything
624  shape2D.collapse(shape2D.num_dimensions());
625  }
626 
627  if(axis == 0)
628  {
629  // If axis is zero the first dim should be one. Since
630  // collapse is an inclusive operation we need to shift
631  shape2D.shift_right(1);
632  }
633 
634  return shape2D;
635 }

References arm_compute::test::validation::axis, TensorShape::collapse(), Dimensions< T >::collapse_from(), arm_compute::test::validation::input, Dimensions< T >::num_dimensions(), and TensorShape::shift_right().

Referenced by CLSoftmaxLayerGeneric< IS_LOG >::validate(), and NESoftmaxLayerGeneric< IS_LOG >::validate().

◆ compute_space_to_batch_shape()

TensorShape arm_compute::misc::shape_calculator::compute_space_to_batch_shape ( const ITensorInfo input,
const int  block_x,
const int  block_y,
const Size2D padding_left,
const Size2D padding_right 
)
inline

Calculate the space to batch output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]block_xBlock shape x value
[in]block_yBlock shape y value
[in]padding_leftLeft padding values
[in]padding_rightRight padding values
Returns
the calculated shape

Definition at line 1120 of file ShapeCalculator.h.

1121 {
1122  TensorShape output_shape{ input->tensor_shape() };
1123 
1124  const DataLayout data_layout = input->data_layout();
1125  const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1126  const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1127  const int idx_batch = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
1128 
1129  output_shape.set(idx_width, input->tensor_shape()[idx_width] * block_x + padding_left.x() + padding_right.x());
1130  output_shape.set(idx_height, input->tensor_shape()[idx_height] * block_y + padding_left.y() + padding_right.y());
1131  output_shape.set(idx_batch, input->tensor_shape()[idx_batch] / (block_x * block_y));
1132 
1133  return output_shape;
1134 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::BATCHES, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, arm_compute::WIDTH, Size2D::x(), and Size2D::y().

Referenced by CLSpaceToBatchLayerKernel::configure(), and NESpaceToBatchLayerKernel::configure().

◆ compute_space_to_depth_shape()

TensorShape arm_compute::misc::shape_calculator::compute_space_to_depth_shape ( const ITensorInfo input,
int32_t  block_shape 
)
inline

Calculate the space to batch output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]block_shapeBlock shape value
Returns
the calculated shape

Definition at line 1143 of file ShapeCalculator.h.

1144 {
1145  TensorShape output_shape{ input->tensor_shape() };
1146 
1147  const DataLayout data_layout = input->data_layout();
1148  const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1149  const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1150  const int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
1151 
1152  output_shape.set(idx_width, input->tensor_shape()[idx_width] * block_shape);
1153  output_shape.set(idx_height, input->tensor_shape()[idx_height] * block_shape);
1154  output_shape.set(idx_depth, input->tensor_shape()[idx_depth] / (block_shape * block_shape));
1155 
1156  return output_shape;
1157 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

Referenced by NESpaceToDepthLayerKernel::configure().

◆ compute_split_shape()

TensorShape arm_compute::misc::shape_calculator::compute_split_shape ( const ITensorInfo input,
unsigned int  axis,
unsigned int  num_splits 
)
inline

Calculate the split output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]axisAxis on which to split the input
[in]num_splitsNumber of splits
Returns
the calculated shape

Definition at line 1085 of file ShapeCalculator.h.

1086 {
1087  TensorShape empty_shape;
1088  empty_shape.set(0, 0);
1089 
1090  TensorShape out_shape{ input->tensor_shape() };
1091 
1092  // Return empty shape if axis is invalid
1093  if(axis > input->tensor_shape().num_dimensions())
1094  {
1095  return empty_shape;
1096  }
1097 
1098  size_t axis_size = out_shape[axis];
1099 
1100  // Return empty shape if num_split is not valid
1101  if(axis_size % num_splits)
1102  {
1103  return empty_shape;
1104  }
1105 
1106  out_shape[axis] = axis_size / num_splits;
1107  return out_shape;
1108 }

References arm_compute::test::validation::axis, arm_compute::test::validation::input, and TensorShape::set().

Referenced by CPPSplit< CLSlice, ICLTensor >::configure(), and CPPSplit< CLSlice, ICLTensor >::validate().

◆ compute_stack_shape()

TensorShape arm_compute::misc::shape_calculator::compute_stack_shape ( const ITensorInfo a,
unsigned int  axis,
unsigned int  num_tensors 
)
inline

Calculate the stack output shape of a tensor.

Parameters
[in]aInput tensor info
[in]axisAxis on which to perform the stack operation
[in]num_tensorsNumber of tensors to stack
Returns
the calculated shape

Definition at line 1357 of file ShapeCalculator.h.

1358 {
1359  ARM_COMPUTE_ERROR_ON(axis > a.num_dimensions());
1360  ARM_COMPUTE_ERROR_ON(a.num_dimensions() > 4);
1361 
1362  TensorShape shape_out{ a.tensor_shape() };
1363  shape_out.set(axis, num_tensors);
1364 
1365  unsigned int i_shift = 0;
1366 
1367  for(unsigned int i = 0; i < a.num_dimensions(); ++i)
1368  {
1369  if(i == axis)
1370  {
1371  i_shift++;
1372  }
1373 
1374  shape_out.set(i + i_shift, a.tensor_shape()[i]);
1375  }
1376  return shape_out;
1377 }
#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

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::axis, ITensorInfo::num_dimensions(), arm_compute::test::validation::num_tensors, TensorShape::set(), and ITensorInfo::tensor_shape().

Referenced by StackLayerNode::compute_output_descriptor().

◆ compute_strided_slice_shape()

TensorShape arm_compute::misc::shape_calculator::compute_strided_slice_shape ( const ITensorInfo input,
const Coordinates starts,
const Coordinates ends,
const Coordinates strides,
int32_t  begin_mask,
int32_t  end_mask,
int32_t  shrink_axis_mask 
)
inline

Calculate the strided slice output shape of a tensor.

Parameters
[in]inputInput tensor info
[in]startsThe starts of the dimensions of the input tensor to be sliced
[in]endsThe ends of the dimensions of the input tensor to be sliced
[in]stridesThe strides of the dimensions of the input tensor to be sliced
[in]begin_maskIf the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
[in]end_maskIf the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
[in]shrink_axis_maskIf the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1
Returns
the calculated shape

Definition at line 1003 of file ShapeCalculator.h.

1006 {
1008  return compute_strided_slice_output_shape(input.tensor_shape(), starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
1009 }
TensorShape compute_strided_slice_output_shape(TensorShape input_shape, Coordinates starts, Coordinates ends, Coordinates strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0, bool return_unshrinked=false)
Computes output shape of strided slice.

References arm_compute::helpers::tensor_transform::compute_strided_slice_output_shape(), and arm_compute::test::validation::input.

◆ compute_tiled_shape()

TensorShape arm_compute::misc::shape_calculator::compute_tiled_shape ( const TensorShape input_shape,
const Multiples multiples 
)
inline

Calculate the tiled shape of a tensor.

Parameters
[in]input_shapeInput tensor shape
[in]multiplesPaddings list
Returns
the calculated shape

Definition at line 1206 of file ShapeCalculator.h.

1207 {
1208  TensorShape tiled_shape = input_shape;
1209  for(size_t dim = 0; dim < multiples.size(); ++dim)
1210  {
1211  tiled_shape.set(dim, input_shape[dim] * multiples[dim]);
1212  }
1213  return tiled_shape;
1214 }

References arm_compute::test::validation::input_shape, and TensorShape::set().

Referenced by CLTileKernel::configure(), NETileKernel::configure(), and arm_compute::test::validation::reference::tile().

◆ compute_transpose1xW_shape()

TensorShape arm_compute::misc::shape_calculator::compute_transpose1xW_shape ( const ITensorInfo b)
inline

Calculate the transposed 1xW shape.

Parameters
[in]bInput tensor info
Returns
the calculated shape

Definition at line 320 of file ShapeCalculator.h.

321 {
322  // The transpose1xW output matrix will have the following shape: [ b_height * 16, ceil(b_width / 16.0f) ]
323  TensorShape shape_transposed1xW_b{ b.tensor_shape() };
324  shape_transposed1xW_b.set(0, b.dimension(1) * 16);
325  shape_transposed1xW_b.set(1, std::ceil(b.dimension(0) / 16.f));
326 
327  return shape_transposed1xW_b;
328 }
SimpleTensor< float > b
Definition: DFT.cpp:157

References arm_compute::test::validation::b.

Referenced by NEGEMMLowpMatrixMultiplyCore::configure().

◆ compute_transpose1xW_with_element_size_shape()

TensorShape arm_compute::misc::shape_calculator::compute_transpose1xW_with_element_size_shape ( const ITensorInfo b,
int  mult_transpose1xW_width = 1 
)
inline

Calculate the transposed 1xW width element shape.

Parameters
[in]bInput tensor info
[in]mult_transpose1xW_width(Optional) Transpose1xW width
Returns
the calculated shape

Definition at line 337 of file ShapeCalculator.h.

338 {
339  // Note: mult_transpose1xW_width expresses the number of chunks with size 1x(W) we want to store on the same row
340  // The transpose1xW output matrix will have the following shape:
341  // [ b_height * W, ceil(b_width / W) ] where W = (16 / element size of the tensor) * mult_transpose1xW_width
342  ARM_COMPUTE_ERROR_ON(mult_transpose1xW_width < 1);
343  TensorShape shape_transposed1xW_b{ b.tensor_shape() };
344  const size_t transpose_width = (16 / b.element_size()) * mult_transpose1xW_width;
345  shape_transposed1xW_b.set(0, b.dimension(1) * transpose_width);
346  shape_transposed1xW_b.set(1, static_cast<size_t>(std::ceil(b.dimension(0) / static_cast<float>(transpose_width))));
347 
348  return shape_transposed1xW_b;
349 }
SimpleTensor< float > b
Definition: DFT.cpp:157
#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

References ARM_COMPUTE_ERROR_ON, and arm_compute::test::validation::b.

Referenced by NEGEMM::validate().

◆ compute_transposed_shape()

TensorShape arm_compute::misc::shape_calculator::compute_transposed_shape ( const ITensorInfo input)
inline

Calculate the transposed shape of a tensor.

Parameters
[in]inputInput tensor info
Returns
the calculated shape

Definition at line 426 of file ShapeCalculator.h.

427 {
428  TensorShape shape_transposed{ input.tensor_shape() };
429 
430  shape_transposed.set(0, input.dimension(1));
431  shape_transposed.set(1, input.dimension(0));
432 
433  return shape_transposed;
434 }

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

Referenced by NELSTMLayer::configure(), CLLSTMLayer::configure(), NELSTMLayer::validate(), CLLSTMLayer::validate(), NEFullyConnectedLayer::validate(), and CLFullyConnectedLayer::validate().

◆ compute_upsample_shape()

TensorShape arm_compute::misc::shape_calculator::compute_upsample_shape ( const ITensorInfo input,
const Size2D info 
)
inline

Calculate the upsampled shape of a tensor.

Parameters
[in]inputInput tensor info
[in]infoContains stride information (x and y)
Returns
the calculated shape

Definition at line 1247 of file ShapeCalculator.h.

1248 {
1249  const DataLayout data_layout = input.data_layout();
1250  const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
1251  const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
1252 
1253  TensorShape scale_out_shape(input.tensor_shape());
1254  const unsigned int out_x = input.dimension(idx_width) * info.x();
1255  const unsigned int out_y = input.dimension(idx_height) * info.y();
1256  scale_out_shape.set(idx_width, out_x);
1257  scale_out_shape.set(idx_height, out_y);
1258 
1259  return scale_out_shape;
1260 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::info, arm_compute::test::validation::input, and arm_compute::WIDTH.

Referenced by CLUpsampleLayerKernel::configure(), and NEUpsampleLayerKernel::configure().

◆ compute_vector_to_tensor_output_shape()

TensorShape arm_compute::misc::shape_calculator::compute_vector_to_tensor_output_shape ( const TensorShape input,
size_t  conv_w,
size_t  conv_h,
const DataLayout data_layout 
)
inline

Calculate the output tensor shape of a vector input given the convolution dimensions.

Parameters
[in]inputInput tensor shape
[in]conv_wConvolution width
[in]conv_hConvolution height
[in]data_layoutData layout
Returns
the calculated shape

Definition at line 87 of file ShapeCalculator.h.

88 {
89  const size_t idx_w = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
90  const size_t idx_h = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
91  const size_t idx_c = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
92 
93  TensorShape output_shape(input);
94  output_shape.set(idx_w, conv_w);
95  output_shape.set(idx_h, conv_h);
96  output_shape.set(idx_c, input.x() / (conv_w * conv_h));
97 
98  return output_shape;
99 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References arm_compute::CHANNEL, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, and arm_compute::WIDTH.

◆ compute_weights_reshaped_shape()

TensorShape arm_compute::misc::shape_calculator::compute_weights_reshaped_shape ( const ITensorInfo weights,
bool  has_bias = false,
unsigned int  num_groups = 1 
)
inline

Calculate the reshaped shape of the weights.

Parameters
[in]weightsWeights tensor info
[in]has_bias(Optional) Set to true if there is bias
[in]num_groups(Optional) Number of groups
Returns
the calculated shape of the reshaped weights

Definition at line 149 of file ShapeCalculator.h.

150 {
151  // Number of groups greater than one are only supported for NCHW data layout, and the number of weights must be a multiple of it.
153  ARM_COMPUTE_ERROR_ON(weights.data_layout() == DataLayout::NHWC && num_groups > 1);
154  ARM_COMPUTE_ERROR_ON((weights.dimension(3) % num_groups) != 0);
155 
156  // Calculate output shape
157  TensorShape weights_reshaped{ weights.tensor_shape() };
158  weights_reshaped.set(3, weights_reshaped[3] / num_groups);
159 
160  weights_reshaped.collapse(3);
161  const size_t tmp_dim = weights_reshaped[0];
162  weights_reshaped.set(0, weights_reshaped[1]);
163  weights_reshaped.set(1, tmp_dim + (has_bias ? 1 : 0));
164  if(weights.num_dimensions() < 5)
165  {
166  weights_reshaped.set(2, num_groups);
167  }
168 
169  return weights_reshaped;
170 }
#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
const unsigned int num_groups
Definition: Im2Col.cpp:148

References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::has_bias, arm_compute::NHWC, arm_compute::test::validation::num_groups, and arm_compute::test::validation::weights.

Referenced by GCWeightsReshapeKernel::configure(), CLWeightsReshapeKernel::configure(), NEGEMMConvolutionLayer::validate(), and CLGEMMConvolutionLayer::validate().

◆ compute_winograd_filter_transform_shape()

TensorShape arm_compute::misc::shape_calculator::compute_winograd_filter_transform_shape ( const ITensorInfo input,
const WinogradInfo winograd_info 
)
inline

Calculate the winograd filter transform shape.

Parameters
[in]inputInput tensor info
[in]winograd_infoWinograd information
Returns
the calculated shape

Definition at line 644 of file ShapeCalculator.h.

645 {
646  TensorShape tensor_shape{ input.tensor_shape() };
647 
648  const Size2D kernel_size = winograd_info.kernel_size;
649  const Size2D output_tile_size = winograd_info.output_tile_size;
650  const Size2D input_tile_size = Size2D(output_tile_size.width + kernel_size.width - 1, output_tile_size.height + kernel_size.height - 1);
651 
652  tensor_shape.remove_dimension(get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH));
653  tensor_shape.set(Window::DimX, input.dimension(3));
654  tensor_shape.set(Window::DimY, input.dimension(get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::CHANNEL)));
655  tensor_shape.set(Window::DimZ, input_tile_size.area());
656 
657  return tensor_shape;
658 }
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References Size2D::area(), arm_compute::CHANNEL, Window::DimX, Window::DimY, Window::DimZ, arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::test::validation::input, Size2D::width, arm_compute::WIDTH, and arm_compute::test::validation::winograd_info.

Referenced by CLWinogradFilterTransformKernel::configure(), NEWinogradConvolutionLayer::validate(), and CLWinogradConvolutionLayer::validate().

◆ compute_winograd_input_transform_shape()

TensorShape arm_compute::misc::shape_calculator::compute_winograd_input_transform_shape ( const ITensorInfo input,
const WinogradInfo winograd_info 
)
inline

Calculate the winograd input transform shape.

Parameters
[in]inputInput tensor info
[in]winograd_infoWinograd information
Returns
the calculated shape

Definition at line 667 of file ShapeCalculator.h.

668 {
669  const PadStrideInfo conv_info = winograd_info.convolution_info;
670  const Size2D kernel_size = winograd_info.kernel_size;
671  const Size2D output_tile_size = winograd_info.output_tile_size;
672  const Size2D input_tile_size = Size2D(output_tile_size.width + kernel_size.width - 1, output_tile_size.height + kernel_size.height - 1);
673 
674  const size_t idx_w = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH);
675  const size_t idx_h = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT);
676  const size_t idx_c = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::CHANNEL);
677 
678  // Compute the number of output tiles along the x and y direction of size "output_tile_size"
679  const Size2D num_tiles = compute_winograd_convolution_tiles(Size2D(input.tensor_shape()[idx_w], input.tensor_shape()[idx_h]),
680  kernel_size,
681  output_tile_size,
682  conv_info);
683 
684  const unsigned int width = input.tensor_shape()[idx_c];
685  const unsigned int height = num_tiles.area();
686  const unsigned int depth = input_tile_size.area();
687 
688  TensorShape output_shape{ input.tensor_shape() };
689  output_shape.set(0, width);
690  output_shape.set(1, height);
691  output_shape.set(2, depth);
692 
693  return output_shape;
694 }
Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info)
Calculate the number of output tiles required by Winograd Convolution layer.
Definition: Helpers.h:744
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References Size2D::area(), arm_compute::CHANNEL, arm_compute::compute_winograd_convolution_tiles(), arm_compute::test::validation::conv_info, arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::test::validation::output_shape, Size2D::width, arm_compute::WIDTH, and arm_compute::test::validation::winograd_info.

Referenced by CLWinogradInputTransformKernel::configure(), NEWinogradConvolutionLayer::validate(), and CLWinogradConvolutionLayer::validate().

◆ compute_winograd_output_transform_shape()

TensorShape arm_compute::misc::shape_calculator::compute_winograd_output_transform_shape ( const ITensorInfo input,
const WinogradInfo winograd_info 
)
inline

Calculate the winograd output transform shape.

Parameters
[in]inputInput tensor info
[in]winograd_infoWinograd information
Returns
the calculated shape

Definition at line 703 of file ShapeCalculator.h.

704 {
705  const PadStrideInfo conv_info = winograd_info.convolution_info;
706  const Size2D kernel_size = winograd_info.kernel_size;
707  const Size2D input_dimensions = winograd_info.input_dimensions;
708  const DataLayout data_layout = winograd_info.output_data_layout;
709 
710  // Compute output shape
711  unsigned int output_width = 0;
712  unsigned int output_height = 0;
713  std::tie(output_width, output_height) = scaled_dimensions(input_dimensions.width, input_dimensions.height,
714  kernel_size.width, kernel_size.height, conv_info);
715 
716  TensorShape tensor_shape{ input.tensor_shape() };
717 
718  // Output dimension
719  const unsigned int out_w = output_width;
720  const unsigned int out_h = output_height;
721  const unsigned int out_c = input.dimension(0);
722 
723  tensor_shape.set(get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH), out_w);
724  tensor_shape.set(get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT), out_h);
725  tensor_shape.set(get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL), out_c);
726 
727  return tensor_shape;
728 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
DataLayout
[DataLayout enum definition]
Definition: Types.h:117

References arm_compute::CHANNEL, arm_compute::test::validation::conv_info, arm_compute::test::validation::data_layout, arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::HEIGHT, arm_compute::test::validation::input, arm_compute::scaled_dimensions(), Size2D::width, arm_compute::WIDTH, and arm_compute::test::validation::winograd_info.

Referenced by CLWinogradOutputTransformKernel::configure().

◆ extract_shape() [1/5]

TensorShape arm_compute::misc::shape_calculator::extract_shape ( T *  data)
inline

Get the tensor shape.

Parameters
[in]dataInput data
Returns
the extracted tensor shape

Definition at line 1269 of file ShapeCalculator.h.

1270 {
1271  return data->info()->tensor_shape();
1272 }

Referenced by calculate_concatenate_shape().

◆ extract_shape() [2/5]

TensorShape arm_compute::misc::shape_calculator::extract_shape ( ITensorInfo data)
inline

Definition at line 1274 of file ShapeCalculator.h.

1275 {
1276  return data->tensor_shape();
1277 }

References ITensorInfo::tensor_shape().

◆ extract_shape() [3/5]

TensorShape arm_compute::misc::shape_calculator::extract_shape ( const ITensorInfo data)
inline

Definition at line 1278 of file ShapeCalculator.h.

1279 {
1280  return data->tensor_shape();
1281 }

References ITensorInfo::tensor_shape().

◆ extract_shape() [4/5]

TensorShape arm_compute::misc::shape_calculator::extract_shape ( const TensorShape data)
inline

Definition at line 1283 of file ShapeCalculator.h.

1284 {
1285  return *data;
1286 }

◆ extract_shape() [5/5]

TensorShape arm_compute::misc::shape_calculator::extract_shape ( TensorShape data)
inline

Definition at line 1288 of file ShapeCalculator.h.

1289 {
1290  return *data;
1291 }