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 },
81 _lock_paddings =
false;
96 init(tensor_shape, format);
108 init(tensor_shape, num_channels, data_type);
114 init(tensor_shape, num_channels, data_type);
115 _quantization_info = std::move(quantization_info);
121 init(tensor_shape, num_channels, data_type);
135 init(tensor_shape, num_channels, type);
142 size_t total_size_in_bytes)
147 init(tensor_shape, num_channels, type, strides_in_bytes, offset_first_element_in_bytes, total_size_in_bytes);
170 size_t total_size_in_bytes)
180 _total_size = total_size_in_bytes;
218 const size_t extra_pad_x = _tensor_shape.
num_dimensions() < 1 ? 0 : 32;
225 std::tuple<Strides, size_t, size_t> TensorInfo::calculate_padding_requirements(
const PaddingSize &
padding)
229 const size_t stride_y = (padding.
left + _tensor_shape[0] + padding.
right) * stride_x;
230 const size_t stride_z = (padding.
top + _tensor_shape[1] + padding.
bottom) * stride_y;
233 size_t required_total_size = 0;
234 const size_t required_offset_first_element = padding.
left * stride_x + padding.
top * stride_y;
242 required_strides =
Strides(stride_x, stride_x);
243 required_total_size = stride_z;
249 required_total_size = stride_z;
253 required_total_size = stride_z;
257 required_strides =
compute_strides(*
this, stride_x, stride_y, stride_z);
259 const unsigned int idx_last_dimension = _tensor_shape.
num_dimensions() - 1;
261 required_total_size =
static_cast<size_t>(_tensor_shape[idx_last_dimension]) * required_strides[idx_last_dimension];
266 return std::make_tuple(required_strides, required_offset_first_element, required_total_size);
271 _lock_paddings = flag;
277 return _lock_paddings;
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 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.
bool is_resizable() const override
Flag indicating whether the size of the tensor can be changed.
Container for 2D border size.
ValidRegion valid_region() const override
Valid region of the tensor.
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.
ITensorInfo & set_lock_paddings(bool flag) override
Set the lock paddings flag of the tensor.
virtual DataType data_type() const =0
Data type used for each element 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.
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
static constexpr Id invalid_tensor_id
An invalid tensor id within a domain.
Store the tensor's metadata.
std::vector< int > TensorDimsState
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-2023 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.
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.
size_t total_size() const override
Returns the total size of the tensor in bytes.
const TensorDimsState & tensor_dims_state() const override
State of each dimension of the tensor shape.
size_t total_size() const
Collapses all dimensions to a single linear total size.
virtual bool are_values_constant() const =0
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
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.
bool are_values_constant() const override
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
unsigned int right
right of the border
virtual Id id() const =0
Get the workload tensor id of the tensor.
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.
bool lock_paddings() const override
Get the lock paddings flag value.
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
ITensorInfo::Id id() const override
Get the workload tensor id 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...
virtual bool lock_paddings() const =0
Get the lock paddings flag value.
#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.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.