24.02.1
|
Store the sub tensor's metadata. More...
#include <SubTensorInfo.h>
Public Member Functions | |
SubTensorInfo () | |
Default constructor. More... | |
SubTensorInfo (ITensorInfo *parent, TensorShape tensor_shape, Coordinates coords, bool extend_parent=false) | |
Default constructor. More... | |
~SubTensorInfo ()=default | |
Default destructor. More... | |
SubTensorInfo (const SubTensorInfo &)=default | |
Allow instances of this class to be copy constructed. More... | |
SubTensorInfo & | operator= (const SubTensorInfo &)=default |
Allow instances of this class to be copied. More... | |
SubTensorInfo (SubTensorInfo &&)=default | |
Allow instances of this class to be move constructed. More... | |
SubTensorInfo & | operator= (SubTensorInfo &&)=default |
Allow instances of this class to be moved. More... | |
Coordinates | coords () const |
Returns the coordinates of the sub-tensor inside the parent tensor. More... | |
std::unique_ptr< ITensorInfo > | clone () const override |
ITensorInfo & | set_data_type (DataType data_type) override |
Set the data type to the specified value. More... | |
ITensorInfo & | set_data_layout (const DataLayout &data_layout) override |
Set the data layout of the tensor. More... | |
ITensorInfo & | set_num_channels (int num_channels) override |
Set the number of channels to the specified value. More... | |
ITensorInfo & | set_format (Format format) override |
Set the format of an already initialized tensor. More... | |
ITensorInfo & | set_tensor_shape (const TensorShape &shape) override |
Set the shape of an already initialized tensor. More... | |
ITensorInfo & | set_tensor_dims_state (const TensorDimsState &state) override |
Set the state for each dimension of the tensor. More... | |
ITensorInfo & | set_quantization_info (const QuantizationInfo &quantization_info) override |
Set the quantization settings (scale and offset) of the tensor. More... | |
ITensorInfo & | reset_padding () override |
Resets the padding settings of the tensor. More... | |
bool | auto_padding () override |
Update the offset to the first element and the strides to automatically computed values. More... | |
ITensorInfo & | set_lock_paddings (bool flag) override |
Set the lock paddings flag of the tensor. More... | |
bool | lock_paddings () const override |
Get the lock paddings flag value. More... | |
bool | extend_padding (const PaddingSize &padding) override |
Update the offset to the first element, the strides and the total size. More... | |
size_t | dimension (size_t index) const override |
Return the size of the requested dimension. More... | |
size_t | dimension (DataLayoutDimension dimension) const override |
Return the size of the requested data layout dimension. More... | |
const Strides & | strides_in_bytes () const override |
The strides in bytes for accessing each dimension of the tensor. More... | |
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. More... | |
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, y, z ...) More... | |
size_t | element_size () const override |
Element size in bytes calculated as data_size() * num_channels() More... | |
size_t | num_dimensions () const override |
The number of dimensions of the tensor (rank) More... | |
size_t | num_channels () const override |
The number of channels for each tensor element. More... | |
const TensorShape & | tensor_shape () const override |
Size for each dimension of the tensor. More... | |
const TensorDimsState & | tensor_dims_state () const override |
State of each dimension of the tensor shape. More... | |
DataType | data_type () const override |
Data type used for each element of the tensor. More... | |
Format | format () const override |
Colour format of the image. More... | |
size_t | total_size () const override |
Returns the total size of the tensor in bytes. More... | |
PaddingSize | padding () const override |
Padding of tensor. More... | |
bool | has_padding () const override |
Checks if the tensor has been allocated with padding or not. More... | |
bool | is_resizable () const override |
Flag indicating whether the size of the tensor can be changed. More... | |
bool | is_dynamic () const override |
Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/function execution. More... | |
bool | are_values_constant () const override |
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel/function execution. More... | |
ITensorInfo & | set_is_resizable (bool is_resizable) override |
Set the flag whether the tensor size can be changed. More... | |
ITensorInfo & | set_are_values_constant (bool are_values_constant) override |
Set the flag whether the tensor values can change during kernel/function execution. More... | |
ValidRegion | valid_region () const override |
Valid region of the tensor. More... | |
void | set_valid_region (const ValidRegion &valid_region) override |
Set the valid region of the tensor. More... | |
QuantizationInfo | quantization_info () const override |
Get the quantization settings (scale and offset) of the tensor. More... | |
DataLayout | data_layout () const override |
Get the data layout of the tensor. More... | |
ITensorInfo::Id | id () const override |
Get the workload tensor id of the tensor. More... | |
ITensorInfo & | set_id (ITensorInfo::Id id) override |
Set the tensor id. More... | |
Public Member Functions inherited from ITensorInfo | |
virtual | ~ITensorInfo ()=default |
Default virtual destructor. More... | |
bool | has_valid_id () const |
Check if the tensor id is valid. More... | |
Public Member Functions inherited from ICloneable< ITensorInfo > | |
virtual | ~ICloneable ()=default |
Default virtual desctructor. More... | |
virtual std::unique_ptr< ITensorInfo > | clone () const=0 |
Provide a clone of the current object of class T. More... | |
Additional Inherited Members | |
Public Types inherited from ITensorInfo | |
using | TensorDimsState = std::vector< int > |
using | Id = int32_t |
An id that uniquely identifies an ITensorInfo within some domain (e.g. More... | |
Static Public Member Functions inherited from ITensorInfo | |
static constexpr int32_t | get_dynamic_state_value () |
Get the value representing dynamic dimension state. More... | |
static constexpr int32_t | get_static_state_value () |
Get the value representing static dimension state. More... | |
template<typename... Infos> | |
static std::pair< TensorShape, ValidRegion > | broadcast_shape_and_valid_region (const Infos &...infos) |
If infos are broadcast compatible tensor info's, return the broadcasted shape and the intersection of the broadcasted valid regions of the tensors. More... | |
Static Public Attributes inherited from ITensorInfo | |
static constexpr Id | invalid_tensor_id = 0 |
An invalid tensor id within a domain. More... | |
Store the sub tensor's metadata.
Definition at line 40 of file SubTensorInfo.h.
SubTensorInfo | ( | ) |
Default constructor.
Definition at line 58 of file SubTensorInfo.cpp.
SubTensorInfo | ( | ITensorInfo * | parent, |
TensorShape | tensor_shape, | ||
Coordinates | coords, | ||
bool | extend_parent = false |
||
) |
Default constructor.
[in] | parent | Metadata of parent tensor. |
[in] | tensor_shape | Tensor shape. Shape must fit inside parent's shape. X and Y dimensions must match the parent's ones. |
[in] | coords | Coordinates of starting element inside parent tensor. |
[in] | extend_parent | (Optional) Extend parent with subtensor shape if subtensor indexes out of bounds |
Definition at line 69 of file SubTensorInfo.cpp.
|
default |
Default destructor.
|
default |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be move constructed.
|
inlineoverridevirtual |
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel/function execution.
Implements ITensorInfo.
Definition at line 204 of file SubTensorInfo.h.
References ITensorInfo::are_values_constant(), and ARM_COMPUTE_ERROR_ON.
Referenced by SubTensorInfo::set_are_values_constant().
|
inlineoverridevirtual |
Update the offset to the first element and the strides to automatically computed values.
Implements ITensorInfo.
Definition at line 113 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::auto_padding().
|
override |
Definition at line 90 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, and ICloneable< T >::clone().
|
inline |
Returns the coordinates of the sub-tensor inside the parent tensor.
Definition at line 68 of file SubTensorInfo.h.
|
inlineoverridevirtual |
Get the data layout of the tensor.
Implements ITensorInfo.
Definition at line 240 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::data_layout().
Referenced by SubTensorInfo::set_data_layout().
|
inlineoverridevirtual |
Data type used for each element of the tensor.
Implements ITensorInfo.
Definition at line 169 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::data_type().
Referenced by SubTensorInfo::set_data_type().
|
inlineoverridevirtual |
Return the size of the requested data layout dimension.
[in] | dimension | DataLayoutDimension of the dimension |
Implements ITensorInfo.
Definition at line 129 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, ITensorInfo::data_layout(), SubTensorInfo::dimension(), and arm_compute::get_data_layout_dimension_index().
|
inlineoverridevirtual |
Return the size of the requested dimension.
[in] | index | Index of the dimension |
Implements ITensorInfo.
Definition at line 125 of file SubTensorInfo.h.
Referenced by SubTensorInfo::dimension().
|
inlineoverridevirtual |
Element size in bytes calculated as data_size() * num_channels()
Implements ITensorInfo.
Definition at line 145 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::element_size().
|
overridevirtual |
Update the offset to the first element, the strides and the total size.
[in] | padding | Padding around the XY plane in number of elements. |
Implements ITensorInfo.
Definition at line 140 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, BorderSize::bottom, ITensorInfo::extend_padding(), ITensorInfo::is_resizable(), BorderSize::left, SubTensorInfo::padding(), BorderSize::right, SubTensorInfo::tensor_shape(), ITensorInfo::tensor_shape(), BorderSize::top, ITensorInfo::total_size(), Dimensions< T >::x(), and Dimensions< T >::y().
Referenced by arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
Colour format of the image.
Implements ITensorInfo.
Definition at line 174 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::format().
Referenced by SubTensorInfo::set_format().
|
inlineoverridevirtual |
Checks if the tensor has been allocated with padding or not.
Implements ITensorInfo.
Definition at line 189 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::has_padding().
|
inlineoverridevirtual |
Get the workload tensor id of the tensor.
Implements ITensorInfo.
Definition at line 245 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::id().
|
inlineoverridevirtual |
Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/function execution.
Implements ITensorInfo.
Definition at line 199 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::is_dynamic().
|
inlineoverridevirtual |
Flag indicating whether the size of the tensor can be changed.
Implements ITensorInfo.
Definition at line 194 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::is_resizable().
Referenced by SubTensorInfo::set_is_resizable().
|
overridevirtual |
Get the lock paddings flag value.
Implements ITensorInfo.
Definition at line 135 of file SubTensorInfo.cpp.
|
inlineoverridevirtual |
The number of channels for each tensor element.
Implements ITensorInfo.
Definition at line 154 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::num_channels().
Referenced by SubTensorInfo::set_num_channels().
|
inlineoverridevirtual |
The number of dimensions of the tensor (rank)
Implements ITensorInfo.
Definition at line 150 of file SubTensorInfo.h.
References Dimensions< T >::num_dimensions().
|
overridevirtual |
The offset in bytes from the beginning of the memory allocation to access the element at position (x, y, z ...)
[in] | pos | Vector with the coordinates of the element to access. The size of this vector must be equal to the number of dimensions of the tensor |
Implements ITensorInfo.
Definition at line 161 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON_COORDINATES_DIMENSIONS_GTE, Dimensions< T >::num_dimensions(), offset(), SubTensorInfo::offset_first_element_in_bytes(), and SubTensorInfo::strides_in_bytes().
|
inlineoverridevirtual |
The offset from the beginning of the memory allocation to the first element of the tensor.
This can be used to access efficiently elements in a 2D tensor
Implements ITensorInfo.
Definition at line 139 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::offset_element_in_bytes().
Referenced by SubTensorInfo::offset_element_in_bytes().
|
default |
Allow instances of this class to be copied.
|
default |
Allow instances of this class to be moved.
|
inlineoverridevirtual |
Padding of tensor.
Implements ITensorInfo.
Definition at line 184 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::padding().
Referenced by SubTensorInfo::extend_padding().
|
inlineoverridevirtual |
Get the quantization settings (scale and offset) of the tensor.
Implements ITensorInfo.
Definition at line 235 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::quantization_info().
Referenced by SubTensorInfo::set_quantization_info().
|
inlineoverridevirtual |
Resets the padding settings of the tensor.
Implements ITensorInfo.
Definition at line 107 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::reset_padding().
|
inlineoverridevirtual |
Set the flag whether the tensor values can change during kernel/function execution.
[in] | are_values_constant | Flag that marks the tensor values if they can be changed or not. |
Implements ITensorInfo.
Definition at line 215 of file SubTensorInfo.h.
References SubTensorInfo::are_values_constant(), ARM_COMPUTE_ERROR_ON, and ITensorInfo::set_are_values_constant().
|
inlineoverridevirtual |
Set the data layout of the tensor.
[in] | data_layout | DataLayout containing the layout data information. |
Implements ITensorInfo.
Definition at line 81 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::data_layout(), and ITensorInfo::set_data_layout().
|
inlineoverridevirtual |
Set the data type to the specified value.
[in] | data_type | The new data type. |
Implements ITensorInfo.
Definition at line 75 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::data_type(), and ITensorInfo::set_data_type().
|
inlineoverridevirtual |
Set the format of an already initialized tensor.
[in] | format | Single-plane format of the tensor. |
Implements ITensorInfo.
Definition at line 93 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::format(), and ITensorInfo::set_format().
|
inlineoverridevirtual |
Set the tensor id.
Implements ITensorInfo.
Definition at line 250 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::set_id().
|
inlineoverridevirtual |
Set the flag whether the tensor size can be changed.
[in] | is_resizable | Flag that marks the tensor if it can be changed or not. |
Implements ITensorInfo.
Definition at line 209 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::is_resizable(), and ITensorInfo::set_is_resizable().
|
overridevirtual |
Set the lock paddings flag of the tensor.
It should be set to True, when the tensor could be mapped to camera or frame buffer.
Implements ITensorInfo.
Definition at line 129 of file SubTensorInfo.cpp.
Referenced by arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
Set the number of channels to the specified value.
[in] | num_channels | New number of channels. |
Implements ITensorInfo.
Definition at line 87 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::num_channels(), and ITensorInfo::set_num_channels().
|
inlineoverridevirtual |
Set the quantization settings (scale and offset) of the tensor.
[in] | quantization_info | QuantizationInfo containing the scale and offset |
Implements ITensorInfo.
Definition at line 101 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::quantization_info(), and ITensorInfo::set_quantization_info().
|
overridevirtual |
Set the state for each dimension of the tensor.
This sets the state of each dimension of the shape in terms of dynamic behavior using -1 where appropriate. The index in the state is a 1 to 1 mapping with the shape dimension index. For example if you want to express [?, 3, 3] as a dynamic input then [-1, 3, 3] has to be set as a state
[in] | state | Tensor dimensions state |
Implements ITensorInfo.
Definition at line 122 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON.
|
overridevirtual |
Set the shape of an already initialized tensor.
[in] | shape | New tensor shape. |
Implements ITensorInfo.
Definition at line 101 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBTENSOR, ITensorInfo::data_type(), ITensorInfo::format(), ITensorInfo::set_tensor_shape(), ITensorInfo::set_valid_region(), arm_compute::test::validation::shape, ITensorInfo::tensor_shape(), TensorShape::total_size(), and arm_compute::UNKNOWN.
|
inlineoverridevirtual |
Set the valid region of the tensor.
[in] | valid_region | Valid region to set. |
Implements ITensorInfo.
Definition at line 225 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBTENSOR_VALID_REGION, ITensorInfo::tensor_shape(), TensorShape::total_size(), SubTensorInfo::valid_region(), and ITensorInfo::valid_region().
|
inlineoverridevirtual |
The strides in bytes for accessing each dimension of the tensor.
Implements ITensorInfo.
Definition at line 134 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::strides_in_bytes().
Referenced by SubTensorInfo::offset_element_in_bytes().
|
inlineoverridevirtual |
State of each dimension of the tensor shape.
Implements ITensorInfo.
Definition at line 164 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON.
|
inlineoverridevirtual |
Size for each dimension of the tensor.
Implements ITensorInfo.
Definition at line 159 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON.
Referenced by SubTensorInfo::extend_padding().
|
inlineoverridevirtual |
Returns the total size of the tensor in bytes.
Implements ITensorInfo.
Definition at line 179 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::total_size().
|
inlineoverridevirtual |
Valid region of the tensor.
All elements in the valid region have defined values, i.e. are not undefined.
Implements ITensorInfo.
Definition at line 221 of file SubTensorInfo.h.
Referenced by SubTensorInfo::set_valid_region().