21.02
|
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 |
Provide a clone of the current object of class T. More... | |
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 |
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... | |
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... | |
ITensorInfo & | set_is_resizable (bool is_resizable) override |
Set the flag whether the tensor size can be changed. 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... | |
Public Member Functions inherited from ITensorInfo | |
virtual | ~ITensorInfo ()=default |
Default virtual destructor. More... | |
virtual ITensorInfo & | set_tensor_dims_state (const TensorDimsState &state)=0 |
Set the state for each dimension of the tensor. More... | |
Public Member Functions inherited from ICloneable< ITensorInfo > | |
virtual | ~ICloneable ()=default |
Default virtual desctructor. More... | |
Additional Inherited Members | |
Public Types inherited from ITensorInfo | |
using | TensorDimsState = Coordinates |
Static Public Member Functions inherited from ITensorInfo | |
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... | |
Store the sub tensor's metadata.
Definition at line 41 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 63 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBTENSOR, SubTensorInfo::coords(), and SubTensorInfo::tensor_shape().
|
default |
Default destructor.
|
default |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be move constructed.
|
inlineoverridevirtual |
Update the offset to the first element and the strides to automatically computed values.
Implements ITensorInfo.
Definition at line 114 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, ITensorInfo::auto_padding(), SubTensorInfo::extend_padding(), and SubTensorInfo::padding().
|
overridevirtual |
Provide a clone of the current object of class T.
Implements ICloneable< ITensorInfo >.
Definition at line 78 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, and ICloneable< T >::clone().
Referenced by SubTensorInfo::coords().
|
inline |
Returns the coordinates of the sub-tensor inside the parent tensor.
Definition at line 69 of file SubTensorInfo.h.
References SubTensorInfo::clone().
Referenced by SubTensorInfo::SubTensorInfo().
|
inlineoverridevirtual |
Get the data layout of the tensor.
Implements ITensorInfo.
Definition at line 224 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::data_layout().
|
inlineoverridevirtual |
Data type used for each element of the tensor.
Implements ITensorInfo.
Definition at line 164 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::data_type().
|
inlineoverridevirtual |
Return the size of the requested dimension.
[in] | index | Index of the dimension |
Implements ITensorInfo.
Definition at line 120 of file SubTensorInfo.h.
Referenced by SubTensorInfo::dimension().
|
inlineoverridevirtual |
Return the size of the requested data layout dimension.
[in] | dimension | DataLayoutDimension of the dimension |
Implements ITensorInfo.
Definition at line 124 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, ITensorInfo::data_layout(), SubTensorInfo::dimension(), and arm_compute::get_data_layout_dimension_index().
|
inlineoverridevirtual |
Element size in bytes calculated as data_size() * num_channels()
Implements ITensorInfo.
Definition at line 140 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 117 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON, BorderSize::bottom, ITensorInfo::extend_padding(), ITensorInfo::is_resizable(), BorderSize::left, BorderSize::right, SubTensorInfo::tensor_shape(), ITensorInfo::tensor_shape(), BorderSize::top, ITensorInfo::total_size(), Dimensions< T >::x(), and Dimensions< T >::y().
Referenced by SubTensorInfo::auto_padding(), and arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
Colour format of the image.
Implements ITensorInfo.
Definition at line 169 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::format().
|
inlineoverridevirtual |
Checks if the tensor has been allocated with padding or not.
Implements ITensorInfo.
Definition at line 184 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::has_padding().
|
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 194 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 189 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::is_resizable().
|
inlineoverridevirtual |
The number of channels for each tensor element.
Implements ITensorInfo.
Definition at line 149 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::num_channels().
|
inlineoverridevirtual |
The number of dimensions of the tensor (rank)
Implements ITensorInfo.
Definition at line 145 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 138 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().
Referenced by SubTensorInfo::offset_first_element_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 134 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, SubTensorInfo::offset_element_in_bytes(), 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 179 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::padding().
Referenced by SubTensorInfo::auto_padding().
|
inlineoverridevirtual |
Get the quantization settings (scale and offset) of the tensor.
Implements ITensorInfo.
Definition at line 219 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::quantization_info().
|
inlineoverridevirtual |
Resets the padding settings of the tensor.
Implements ITensorInfo.
Definition at line 108 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::reset_padding().
|
inlineoverridevirtual |
Set the data layout of the tensor.
[in] | data_layout | DataLayout containing the layout data information. |
Implements ITensorInfo.
Definition at line 82 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, 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 76 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, 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 94 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, ITensorInfo::set_format(), SubTensorInfo::set_tensor_dims_state(), SubTensorInfo::set_tensor_shape(), and arm_compute::test::validation::shape.
|
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 199 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::set_is_resizable().
|
inlineoverridevirtual |
Set the number of channels to the specified value.
[in] | num_channels | New number of channels. |
Implements ITensorInfo.
Definition at line 88 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, 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 102 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON, and ITensorInfo::set_quantization_info().
|
override |
Definition at line 110 of file SubTensorInfo.cpp.
References ARM_COMPUTE_ERROR_ON.
Referenced by SubTensorInfo::set_format().
|
overridevirtual |
Set the shape of an already initialized tensor.
[in] | shape | New tensor shape. |
Implements ITensorInfo.
Definition at line 89 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.
Referenced by SubTensorInfo::set_format().
|
inlineoverridevirtual |
Set the valid region of the tensor.
[in] | valid_region | Valid region to set. |
Implements ITensorInfo.
Definition at line 209 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 129 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 159 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON.
|
inlineoverridevirtual |
Size for each dimension of the tensor.
Implements ITensorInfo.
Definition at line 154 of file SubTensorInfo.h.
References ARM_COMPUTE_ERROR_ON.
Referenced by SubTensorInfo::extend_padding(), and SubTensorInfo::SubTensorInfo().
|
inlineoverridevirtual |
Returns the total size of the tensor in bytes.
Implements ITensorInfo.
Definition at line 174 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 205 of file SubTensorInfo.h.
Referenced by SubTensorInfo::set_valid_region().