38 : _total_size(0), _offset_first_element_in_bytes(0), _strides_in_bytes(), _num_channels(0), _tensor_shape(), _dims_state(), _data_type(
DataType::
UNKNOWN), _format(
Format::
UNKNOWN), _is_resizable{
true },
74 init(tensor_shape, format);
86 init(tensor_shape, num_channels, data_type);
92 init(tensor_shape, num_channels, data_type);
93 _quantization_info = std::move(quantization_info);
99 init(tensor_shape, num_channels, data_type);
106 init(hog_info, width, height);
119 init(tensor_shape, num_channels, type);
126 size_t total_size_in_bytes)
131 init(tensor_shape, num_channels, type, strides_in_bytes, offset_first_element_in_bytes, total_size_in_bytes);
154 size_t total_size_in_bytes)
164 _total_size = total_size_in_bytes;
230 const size_t extra_pad_x = _tensor_shape.
num_dimensions() < 1 ? 0 : 32;
237 std::tuple<Strides, size_t, size_t> TensorInfo::calculate_padding_requirements(
const PaddingSize &
padding)
241 const size_t stride_y = (padding.
left + _tensor_shape[0] + padding.
right) * stride_x;
242 const size_t stride_z = (padding.
top + _tensor_shape[1] + padding.
bottom) * stride_y;
245 size_t required_total_size = 0;
246 const size_t required_offset_first_element = padding.
left * stride_x + padding.
top * stride_y;
254 required_strides =
Strides(stride_x, stride_x);
255 required_total_size = stride_z;
261 required_total_size = stride_z;
265 required_total_size = stride_z;
269 required_strides =
compute_strides(*
this, stride_x, stride_y, stride_z);
271 const unsigned int idx_last_dimension = _tensor_shape.
num_dimensions() - 1;
273 required_total_size =
static_cast<size_t>(_tensor_shape[idx_last_dimension]) * required_strides[idx_last_dimension];
278 return std::make_tuple(required_strides, required_offset_first_element, required_total_size);
285 bool updated =
false;
287 if(padding.
top > _padding.
top)
289 _padding.
top = padding.
top;
311 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
318 return std::make_unique<TensorInfo>(*this);
354 _tensor_shape =
shape;
355 _offset_first_element_in_bytes = 0;
360 _total_size = _strides_in_bytes[0];
364 const unsigned int idx_last_dimension = _tensor_shape.
num_dimensions() - 1;
365 _total_size =
static_cast<size_t>(_tensor_shape[idx_last_dimension]) * _strides_in_bytes[idx_last_dimension];
368 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
397 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
406 int32_t
offset = _offset_first_element_in_bytes;
410 offset += pos[i] * _strides_in_bytes[i];
ITensorInfo & set_format(Format format) override
Set the format of an already initialized tensor.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
unsigned int top
top of the border
size_t num_bins() const
The number of histogram bins for each cell.
size_t init_auto_padding(const TensorShape &tensor_shape, Format format)
Initialize the metadata structure for the given tensor shape and single-plane format, (Padding is automatically calculated)
std::unique_ptr< ITensorInfo > clone() const override
Provide a clone of the current object of class T.
Container for 2D border size.
size_t num_channels() const override
The number of channels for each tensor element.
ITensorInfo & reset_padding() override
Resets the padding settings of the tensor.
DataLayout data_layout() const override
Get the data layout of the tensor.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
Store the HOG's metadata.
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
bool extend_padding(const PaddingSize &padding) override
Update the offset to the first element, the strides and the total size.
1 channel, 1 F32 per channel
ITensorInfo & set_data_type(DataType data_type) override
Set the data type to the specified value.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Store the tensor's metadata.
unsigned int bottom
bottom of the border
PaddingSize padding() const override
Padding of tensor.
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
decltype(strategy::transforms) typedef type
bool auto_padding() override
Update the offset to the first element and the strides to automatically computed values.
Copyright (c) 2017-2021 Arm Limited.
size_t height
Height of the image region or rectangle.
Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fixed_strides)
Create a strides object based on the provided strides and the tensor dimensions.
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
Format format() const override
Colour format of the image.
ITensorInfo & set_quantization_info(const QuantizationInfo &quantization_info) override
Set the quantization settings (scale and offset) of the tensor.
DataType data_type() const override
Data type used for each element of the tensor.
virtual bool is_resizable() const =0
Flag indicating whether the size of the tensor can be changed.
Quantization information.
virtual Format format() const =0
Colour format of the image.
ITensorInfo & set_data_layout(const DataLayout &data_layout) override
Set the data layout of the tensor.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Format
Image colour formats.
Size2D num_cells_per_block() const
Calculates the number of cells for each block.
size_t total_size() const override
Returns the total size of the tensor in bytes.
size_t total_size() const
Collapses all dimensions to a single linear total size.
virtual PaddingSize padding() const =0
Padding of tensor.
BorderSize PaddingSize
Container for 2D padding size.
unsigned int left
left of the border
ITensorInfo & set_num_channels(int num_channels) override
Set the number of channels to the specified value.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
unsigned int right
right of the border
Num samples, channels, height, width.
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
void init(Format format)
Initialize the tensor info with just a format.
Strides of an item in bytes.
virtual size_t offset_first_element_in_bytes() const =0
The offset from the beginning of the memory allocation to the first element of the tensor...
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensorInfo & set_tensor_dims_state(const TensorDimsState &state) override
Set the state for each dimension of the tensor.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
size_t width
Width of the image region or rectangle.
Size2D num_block_positions_per_image(const Size2D &image_size) const
Calculates the number of block positions for the given image size.
Class for specifying the size of an image or rectangle.
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
int32_t offset_element_in_bytes(const Coordinates &pos) const override
The offset in bytes from the beginning of the memory allocation to access the element at position (x...
#define ARM_COMPUTE_ERROR_ON_COORDINATES_DIMENSIONS_GTE(p, md)
size_t offset_first_element_in_bytes() const override
The offset from the beginning of the memory allocation to the first element of the tensor...
Store the tensor's metadata.
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
TensorInfo()
Default constructor.
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
virtual const TensorDimsState & tensor_dims_state() const =0
State of each dimension of the tensor shape.
Container for valid region of a window.
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
DataType
Available data types.
DataLayout
[DataLayout enum definition]
size_t element_size() const override
Element size in bytes calculated as data_size() * num_channels()
virtual size_t num_channels() const =0
The number of channels for each tensor element.
size_t area() const
The area of the image or rectangle calculated as (width * height)
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.