37 : _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 },
45 _total_size =
info.total_size();
46 _offset_first_element_in_bytes =
info.offset_first_element_in_bytes();
47 _strides_in_bytes =
info.strides_in_bytes();
48 _num_channels =
info.num_channels();
49 _tensor_shape =
info.tensor_shape();
50 _dims_state =
info.tensor_dims_state();
51 _data_type =
info.data_type();
52 _format =
info.format();
53 _is_resizable =
info.is_resizable();
54 _valid_region =
info.valid_region();
55 _padding =
info.padding();
56 _quantization_info =
info.quantization_info();
118 const Strides &strides_in_bytes,
size_t offset_first_element_in_bytes,
119 size_t total_size_in_bytes)
146 const Strides &strides_in_bytes,
size_t offset_first_element_in_bytes,
147 size_t total_size_in_bytes)
157 _total_size = total_size_in_bytes;
195 const size_t extra_pad_x = _tensor_shape.
num_dimensions() < 1 ? 0 : 32;
202 std::tuple<Strides, size_t, size_t> TensorInfo::calculate_padding_requirements(
const PaddingSize &padding)
210 size_t required_total_size = 0;
219 required_strides =
Strides(stride_x, stride_x);
220 required_total_size = stride_z;
226 required_total_size = stride_z;
230 required_total_size = stride_z;
234 required_strides =
compute_strides(*
this, stride_x, stride_y, stride_z);
236 const unsigned int idx_last_dimension = _tensor_shape.
num_dimensions() - 1;
238 required_total_size = static_cast<size_t>(_tensor_shape[idx_last_dimension]) * required_strides[idx_last_dimension];
243 return std::make_tuple(required_strides, required_offset_first_element, required_total_size);
250 bool updated =
false;
276 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
283 return std::make_unique<TensorInfo>(*
this);
319 _tensor_shape =
shape;
320 _offset_first_element_in_bytes = 0;
325 _total_size = _strides_in_bytes[0];
329 const unsigned int idx_last_dimension = _tensor_shape.
num_dimensions() - 1;
330 _total_size = static_cast<size_t>(_tensor_shape[idx_last_dimension]) * _strides_in_bytes[idx_last_dimension];
333 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
362 std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
371 int32_t
offset = _offset_first_element_in_bytes;
375 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 init_auto_padding(const TensorShape &tensor_shape, Format format)
Initialize the metadata structure for the given tensor shape and single-plane format,...
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.
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.
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.
const DataLayout data_layout
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.
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.
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.
Quantization information.
ITensorInfo & set_data_layout(const DataLayout &data_layout) override
Set the data layout of the tensor.
Format
Image colour formats.
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.
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.
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.
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.
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.
Container for valid region of a window.
DataLayout data_layout
Data layout to use.
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()