24 #ifndef __ARM_COMPUTE_MISC_SHAPE_CALCULATOR_H__ 25 #define __ARM_COMPUTE_MISC_SHAPE_CALCULATOR_H__ 37 namespace shape_calculator
50 const size_t tmp_dim = weights_reshaped[0];
51 weights_reshaped.set(0, weights_reshaped[1]);
52 weights_reshaped.set(1, tmp_dim + (has_bias ? 1 : 0));
54 return weights_reshaped;
60 const int interleave_width = 4 * mult_interleave4x4_height;
62 shape_interleaved_a.
set(0, a.
dimension(0) * interleave_width);
63 shape_interleaved_a.
set(1, std::ceil(a.
dimension(1) /
static_cast<float>(interleave_width)));
65 return shape_interleaved_a;
72 shape_transposed1xW_b.
set(1, std::ceil(b.
dimension(0) / 16.f));
74 return shape_transposed1xW_b;
83 const size_t transpose_width = (16 / b.
element_size()) * mult_transpose1xW_width;
84 shape_transposed1xW_b.
set(0, b.
dimension(1) * transpose_width);
85 shape_transposed1xW_b.
set(1, static_cast<size_t>(std::ceil(b.
dimension(0) /
static_cast<float>(transpose_width))));
87 return shape_transposed1xW_b;
92 if(shape_vector_sum_col.num_dimensions() > 1)
97 return shape_vector_sum_col;
108 return shape_vector_sum_row;
113 col2im_shape.
set(0, convolved_dims.first);
114 col2im_shape.
set(1, convolved_dims.second);
126 return shape_transposed;
138 unsigned int output_width = 0;
139 unsigned int output_height = 0;
140 std::tie(output_width, output_height) =
scaled_dimensions(input_shape[width_idx], input_shape[height_idx],
141 weights_shape[width_idx], weights_shape[height_idx],
147 output_shape.set(channel_idx, input_shape[channel_idx] * depth_multiplier);
154 const unsigned int out_x = input.
dimension(0) + (input.
dimension(0) - 1) * (sx - 1) + inner_border_right + 2 * info.
pad().first;
155 const unsigned int out_y = input.
dimension(1) + (input.
dimension(1) - 1) * (sy - 1) + inner_border_top + 2 * info.
pad().second;
156 scale_out_shape.set(0, out_x);
157 scale_out_shape.set(1, out_y);
159 return scale_out_shape;
174 output_shape.set(1, (out_dims.first * out_dims.second));
216 if(transpose_weights)
222 if(is_batched_fc_layer)
258 const unsigned int height = num_tiles_x * num_tiles_y;
259 const unsigned int depth = input_tile_size.
area();
276 unsigned int output_width = 0;
277 unsigned int output_height = 0;
284 const unsigned int out_w = output_width;
285 const unsigned int out_h = output_height;
286 const unsigned int out_c = input.
dimension(0);
303 const unsigned int input_width = input_shape[idx_width];
304 const unsigned int input_height = input_shape[idx_height];
305 const unsigned int weights_width = weights_shape[idx_width];
306 const unsigned int weights_height = weights_shape[idx_height];
307 const unsigned int weights_out_channel = weights_shape[3];
308 unsigned int output_width = 0;
309 unsigned int output_height = 0;
310 std::tie(output_width, output_height) =
scaled_dimensions(input_width, input_height, weights_width, weights_height, conv_info);
331 unsigned int pooled_w = 0;
332 unsigned int pooled_h = 0;
364 tensor_shape.
set(0, is_interleaved_transposed ? reshape_info.
n() : input1.
dimension(0));
365 tensor_shape.
set(1, is_interleaved_transposed ? reshape_info.
m() : input0.
dimension(1));
370 template <
typename T>
373 return info->info()->tensor_shape();
381 template <
typename T>
387 for(
const auto &tensor : inputs_vector)
394 out_shape.
set(0, width);
TensorShape compute_im2col_flatten_shape(const ITensorInfo *input)
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
TensorShape compute_permutation_output_shape(const ITensorInfo &input, const PermutationVector &perm)
const Size2D & pool_size() const
Get the pooling size.
void remove_dimension(size_t n)
Accessor to remove the dimension n from the tensor shape.
TensorShape compute_winograd_input_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
DataLayout output_data_layout
Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC) ...
TensorShape compute_transpose1xW_with_element_size_shape(const ITensorInfo &b, int mult_transpose1xW_width=1)
std::pair< unsigned int, unsigned int > pad() const
Get the padding.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
TensorShape compute_interleaved_shape(const ITensorInfo &a, int mult_interleave4x4_height=1)
TensorShape compute_deep_convolution_shape(const ITensorInfo &input, const ITensorInfo &weights, PadStrideInfo conv_info)
GEMM reshape information class.
PadStrideInfo convolution_info
Convolution info (Pads, strides,...)
TensorShape calculate_width_concatenate_shape(const std::vector< T * > &inputs_vector)
TensorShape compute_mm_shape(const ITensorInfo &input0, const ITensorInfo &input1, bool is_interleaved_transposed, const GEMMReshapeInfo &reshape_info)
TensorShape compute_reductionA_shape(const ITensorInfo &b)
PadStrideInfo pad_stride_info() const
Get the padding and stride.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
TensorShape compute_rnn_shape(const ITensorInfo *input, const unsigned int batch_size)
Store the tensor's metadata.
TensorShape compute_interleave_custom_shape(const TensorShape &input, const int x_interleave, const int y_interleave)
src info() -> set_format(Format::S16)
This file contains all available output stages for GEMMLowp on OpenCL.
size_t height
Height of the image region or rectangle.
TensorShape compute_min_max_shape(const ITensorInfo *input)
TensorShape compute_weights_reshaped_shape(const ITensorInfo &weights, bool has_bias=false)
TensorShape compute_transposed_shape(const ITensorInfo &input)
T x() const
Alias to access the size of the first dimension.
void permute(Dimensions< T > &dimensions, const PermutationVector &perm)
Permutes given Dimensions according to a permutation vector.
TensorShape compute_deconvolution_shape(const ITensorInfo &input, unsigned int sx, unsigned int sy, unsigned int inner_border_right, unsigned int inner_border_top, const PadStrideInfo &info)
TensorShape compute_pool_shape(const ITensorInfo &input, PoolingLayerInfo pool_info)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Size2D output_tile_size
Width and height of the output tile.
TensorShape compute_depthwise_convolution_shape(const ITensorInfo &input, const ITensorInfo &weights, PadStrideInfo conv_info, unsigned int depth_multiplier)
TensorShape compute_col2im_shape(const ITensorInfo &input, std::pair< unsigned int, unsigned int > convolved_dims)
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
unsigned int pad_bottom() const
Get the bottom padding.
Padding and stride information class.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
TensorShape compute_winograd_filter_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
TensorShape compute_im2col_conv_shape(const ITensorInfo *input, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation)
TensorShape get_shape_from_info(T *info)
unsigned int pad_right() const
Get the right padding.
Strides of an item in bytes.
TensorShape compute_fully_connected_reshaped_weights_shape(const ITensorInfo *input, bool transpose_weights, bool is_batched_fc_layer, const int interleave)
TensorShape compute_reductionB_shape(const ITensorInfo &a)
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
TensorShape compute_winograd_output_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
size_t width
Width of the image region or rectangle.
T y() const
Alias to access the size of the second dimension.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
unsigned int pad_left() const
Get the left padding.
Class for specifying the size of an image or rectangle.
const std::pair< unsigned int, unsigned int > scaled_dimensions(unsigned int width, unsigned int height, unsigned int kernel_width, unsigned 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...
int m() const
Number of matrix A rows.
TensorShape compute_transpose1xW_shape(const ITensorInfo &b)
int n() const
Number of matrix B columns.
Size2D kernel_size
Width and height of the kernel.
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true)
Accessor to set the value of one of the dimensions.
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
TensorShape compute_im2col_fc_shape(const ITensorInfo *input, const int num_input_dimensions=3)
Size2D input_dimensions
Width and height of the input tensor before the convolution is applied.
bool is_global_pooling() const
Check if is global pooling.
Pooling Layer Information class.
DataLayout
Supported tensor data layouts.
size_t area() const
The area of the image or rectangle calculated as (width * height)
void collapse(size_t n, size_t first=0)
Collapse the first n dimensions.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
unsigned int pad_top() const
Get the top padding.