Compute Library
18.05
|
Store the tensor's metadata. More...
#include <TensorInfo.h>
Public Member Functions | |
TensorInfo () | |
Default constructor. More... | |
~TensorInfo ()=default | |
Default destructor. More... | |
TensorInfo (const ITensorInfo &info) | |
Allow instances of this class to be copy constructed. More... | |
TensorInfo (const TensorInfo &)=default | |
Allow instances of this class to be copy constructed. More... | |
TensorInfo & | operator= (const TensorInfo &)=default |
Allow instances of this class to be copied. More... | |
TensorInfo (TensorInfo &&)=default | |
Allow instances of this class to be move constructed. More... | |
TensorInfo & | operator= (TensorInfo &&)=default |
Allow instances of this class to be moved. More... | |
TensorInfo (Format format) | |
Construct a tensor info with a format. More... | |
TensorInfo (unsigned int width, unsigned int height, Format format) | |
2D tensor constructor More... | |
TensorInfo (const TensorShape &tensor_shape, Format format) | |
Constructor. More... | |
TensorInfo (size_t num_channels, DataType data_type, size_t fixed_point_position=0) | |
Construct a tensor info with a data type and number of channels. More... | |
TensorInfo (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, int fixed_point_position=0) | |
Constructor. More... | |
TensorInfo (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, QuantizationInfo quantization_info) | |
Constructor. More... | |
TensorInfo (const HOGInfo &hog_info, unsigned int width, unsigned int height) | |
Constructor. More... | |
void | init (Format format) |
Initialize the tensor info with just a format. More... | |
void | init (const TensorShape &tensor_shape, Format format) |
Initialize the metadata structure with the given parameters. More... | |
void | init (const TensorShape &tensor_shape, Format format, const Strides &strides_in_bytes, size_t offset_first_element_in_bytes, size_t total_size_in_bytes) |
Initialize the metadata structure with the given parameters. More... | |
void | init (size_t num_channels, DataType data_type, size_t fixed_point_position=0) |
Initialize the tensor info with just a format. More... | |
void | init (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, int fixed_point_position=0) |
Initialize the metadata structure with the given parameters. More... | |
void | init (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, const Strides &strides_in_bytes, size_t offset_first_element_in_bytes, size_t total_size_in_bytes, int fixed_point_position=0) |
Initialize the metadata structure with the given parameters. More... | |
void | init (const HOGInfo &hog_info, unsigned int width, unsigned int height) |
Initialize the metadata structure for the given HOG's metadata. More... | |
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) More... | |
size_t | init_auto_padding (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, int fixed_point_position=0) |
Initialize the metadata structure for the given tensor shape, number of channels, data type and fixed point position. More... | |
size_t | init_auto_padding (const HOGInfo &hog_info, unsigned int width, unsigned int height) |
Initialize the metadata structure for the given HOG's metadata. 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_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_fixed_point_position (int fixed_point_position) override |
Set the fixed point position to the specified value. More... | |
ITensorInfo & | set_quantization_info (const QuantizationInfo &quantization_info) override |
Set the quantization settings (scale and offset) of the tensor. More... | |
ITensorInfo & | set_data_layout (const DataLayout &data_layout) override |
Set the data layout 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... | |
size_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... | |
int | fixed_point_position () const override |
Fixed point position used when the tensor data type is QS8 or QS16. 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... | |
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... | |
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... | |
Public Member Functions inherited from ICloneable< ITensorInfo > | |
virtual | ~ICloneable ()=default |
Default virtual desctructor. More... | |
Additional Inherited Members | |
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 tensor's metadata.
Definition at line 45 of file TensorInfo.h.
TensorInfo | ( | ) |
Default constructor.
|
default |
Default destructor.
TensorInfo | ( | const ITensorInfo & | info | ) |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be move constructed.
TensorInfo | ( | Format | format | ) |
Construct a tensor info with a format.
Can be used for automatic derivation of the shape by the function.
[in] | format | Format of the tensor. |
TensorInfo | ( | unsigned int | width, |
unsigned int | height, | ||
Format | format | ||
) |
2D tensor constructor
[in] | width | Width of the 2D tensor |
[in] | height | Height of the 2D tensor |
[in] | format | Single plane format of the tensor. |
TensorInfo | ( | const TensorShape & | tensor_shape, |
Format | format | ||
) |
Constructor.
[in] | tensor_shape | It specifies the size for each dimension of the tensor in number of elements. |
[in] | format | Single plane format of the tensor. |
TensorInfo | ( | size_t | num_channels, |
DataType | data_type, | ||
size_t | fixed_point_position = 0 |
||
) |
Construct a tensor info with a data type and number of channels.
Can be used for automatic derivation of the shape by the function.
[in] | num_channels | It indicates the number of channels for each tensor element |
[in] | data_type | Data type to use for each tensor element |
[in] | fixed_point_position | (Optional) It specifies the fixed point position when the tensor data type is QS8, QS16 or QS32. |
TensorInfo | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
int | fixed_point_position = 0 |
||
) |
Constructor.
[in] | tensor_shape | It specifies the size for each dimension of the tensor in number of elements. |
[in] | num_channels | It indicates the number of channels for each tensor element |
[in] | data_type | Data type to use for each tensor element |
[in] | fixed_point_position | (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16. |
TensorInfo | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
QuantizationInfo | quantization_info | ||
) |
Constructor.
[in] | tensor_shape | It specifies the size for each dimension of the tensor in number of elements. |
[in] | num_channels | It indicates the number of channels for each tensor element |
[in] | data_type | Data type to use for each tensor element |
[in] | quantization_info | The quantization settings for the tensor data. |
TensorInfo | ( | const HOGInfo & | hog_info, |
unsigned int | width, | ||
unsigned int | height | ||
) |
|
overridevirtual |
Update the offset to the first element and the strides to automatically computed values.
Implements ITensorInfo.
|
overridevirtual |
Provide a clone of the current object of class T.
Implements ICloneable< ITensorInfo >.
Referenced by arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
Get the data layout of the tensor.
Implements ITensorInfo.
Definition at line 308 of file TensorInfo.h.
Referenced by GCAccessor::data_layout(), and CLAccessor::data_layout().
|
inlineoverridevirtual |
Data type used for each element of the tensor.
Implements ITensorInfo.
Definition at line 267 of file TensorInfo.h.
Referenced by GCAccessor::data_type(), CLAccessor::data_type(), arm_compute::test::validation::TEST_CASE(), and arm_compute::to_string().
|
inlineoverridevirtual |
Return the size of the requested dimension.
[in] | index | Index of the dimension |
Implements ITensorInfo.
Definition at line 230 of file TensorInfo.h.
|
inlineoverridevirtual |
Return the size of the requested data layout dimension.
[in] | dimension | DataLayoutDimension of the dimension |
Implements ITensorInfo.
Definition at line 234 of file TensorInfo.h.
References arm_compute::get_data_layout_dimension_index().
|
inlineoverridevirtual |
Element size in bytes calculated as data_size() * num_channels()
Implements ITensorInfo.
Definition at line 251 of file TensorInfo.h.
References arm_compute::data_size_from_type().
Referenced by GCAccessor::element_size(), and CLAccessor::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.
Referenced by arm_compute::test::validation::DATA_TEST_CASE().
|
inlineoverridevirtual |
Fixed point position used when the tensor data type is QS8 or QS16.
Implements ITensorInfo.
Definition at line 247 of file TensorInfo.h.
Referenced by GCAccessor::fixed_point_position(), CLAccessor::fixed_point_position(), arm_compute::test::validation::TEST_CASE(), and arm_compute::to_string().
|
inlineoverridevirtual |
Colour format of the image.
Implements ITensorInfo.
Definition at line 271 of file TensorInfo.h.
Referenced by GCAccessor::format(), and CLAccessor::format().
|
inlineoverridevirtual |
Checks if the tensor has been allocated with padding or not.
Implements ITensorInfo.
Definition at line 283 of file TensorInfo.h.
References BorderSize::empty().
void init | ( | Format | format | ) |
Initialize the tensor info with just a format.
Can be used for automatic derivation of the shape by the function.
[in] | format | Single plane format of the tensor. |
void init | ( | const TensorShape & | tensor_shape, |
Format | format | ||
) |
Initialize the metadata structure with the given parameters.
[in] | tensor_shape | Size for each dimension of the tensor in number of elements. |
[in] | format | Single plane format of the tensor. |
void init | ( | const TensorShape & | tensor_shape, |
Format | format, | ||
const Strides & | strides_in_bytes, | ||
size_t | offset_first_element_in_bytes, | ||
size_t | total_size_in_bytes | ||
) |
Initialize the metadata structure with the given parameters.
[in] | tensor_shape | Size for each dimension of the tensor in number of elements. |
[in] | format | Single plane format of the tensor. |
[in] | strides_in_bytes | Stride in bytes for accessing each dimension of the tensor. |
[in] | offset_first_element_in_bytes | Offset in bytes from the beginning of memory allocation to access the first element. |
[in] | total_size_in_bytes | Size in bytes of the memory allocation (including the offset to the first element). |
void init | ( | size_t | num_channels, |
DataType | data_type, | ||
size_t | fixed_point_position = 0 |
||
) |
Initialize the tensor info with just a format.
Can be used for automatic derivation of the shape by the function.
[in] | num_channels | Desired number of channels for each tensor element. |
[in] | data_type | Data type to use for each tensor element. |
[in] | fixed_point_position | (Optional) Fixed point position when the tensor data type is QS8, QS16 or QS32. |
void init | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
int | fixed_point_position = 0 |
||
) |
Initialize the metadata structure with the given parameters.
[in] | tensor_shape | Size for each dimension of the tensor in number of elements. |
[in] | num_channels | Desired number of channels for each tensor element. |
[in] | data_type | Data type to use for each tensor element. |
[in] | fixed_point_position | (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16. |
void init | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
const Strides & | strides_in_bytes, | ||
size_t | offset_first_element_in_bytes, | ||
size_t | total_size_in_bytes, | ||
int | fixed_point_position = 0 |
||
) |
Initialize the metadata structure with the given parameters.
[in] | tensor_shape | Size for each dimension of the tensor in number of elements. |
[in] | num_channels | Desired number of channels for each tensor element. |
[in] | data_type | Data type to use for each tensor element. |
[in] | strides_in_bytes | Stride in bytes for accessing each dimension of the tensor. |
[in] | offset_first_element_in_bytes | Offset in bytes from the beginning of memory allocation to access the first element. |
[in] | total_size_in_bytes | Size in bytes of the memory allocation (including the offset to the first element). |
[in] | fixed_point_position | (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16. |
void init | ( | const HOGInfo & | hog_info, |
unsigned int | width, | ||
unsigned int | height | ||
) |
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)
[in] | tensor_shape | It specifies the size for each dimension of the tensor in number of elements |
[in] | format | Single plane format of the image. |
size_t init_auto_padding | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
int | fixed_point_position = 0 |
||
) |
Initialize the metadata structure for the given tensor shape, number of channels, data type and fixed point position.
(Padding is automatically calculated)
[in] | tensor_shape | It specifies the size for each dimension of the tensor in number of elements |
[in] | num_channels | It indicates the number of channels for each tensor element |
[in] | data_type | Data type to use for each tensor element |
[in] | fixed_point_position | (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16. |
size_t init_auto_padding | ( | const HOGInfo & | hog_info, |
unsigned int | width, | ||
unsigned int | height | ||
) |
Initialize the metadata structure for the given HOG's metadata.
[in] | hog_info | HOG's metadata used to allocate normalized HOG space |
[in] | width | Width of the 2D tensor where the HOG descriptor will be computed on |
[in] | height | Height of the 2D tensor where the HOG descriptor will be computed on |
|
inlineoverridevirtual |
Flag indicating whether the size of the tensor can be changed.
Implements ITensorInfo.
Definition at line 287 of file TensorInfo.h.
Referenced by arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::test::validation::FIXTURE_DATA_TEST_CASE(), TensorInfo::set_is_resizable(), and arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
The number of channels for each tensor element.
Implements ITensorInfo.
Definition at line 259 of file TensorInfo.h.
Referenced by arm_compute::test::validation::reference::hog_multi_detection(), GCAccessor::num_channels(), CLAccessor::num_channels(), arm_compute::test::validation::TEST_CASE(), and arm_compute::to_string().
|
inlineoverridevirtual |
The number of dimensions of the tensor (rank)
Implements ITensorInfo.
Definition at line 255 of file TensorInfo.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.
Referenced by TensorInfo::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 242 of file TensorInfo.h.
References TensorInfo::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 279 of file TensorInfo.h.
Referenced by arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::test::validation::FIXTURE_DATA_TEST_CASE(), GCAccessor::padding(), and CLAccessor::padding().
|
inlineoverridevirtual |
Get the quantization settings (scale and offset) of the tensor.
Implements ITensorInfo.
Definition at line 304 of file TensorInfo.h.
Referenced by arm_compute::test::validation::DATA_TEST_CASE(), GCAccessor::quantization_info(), CLAccessor::quantization_info(), and arm_compute::test::validation::TEST_CASE().
|
overridevirtual |
Resets the padding settings of the tensor.
Implements ITensorInfo.
|
overridevirtual |
Set the data layout of the tensor.
[in] | data_layout | DataLayout containing the layout data information. |
Implements ITensorInfo.
Referenced by arm_compute::test::create_tensor().
|
overridevirtual |
Set the data type to the specified value.
[in] | data_type | The new data type. |
Implements ITensorInfo.
Referenced by arm_compute::test::validation::TEST_CASE().
|
overridevirtual |
Set the fixed point position to the specified value.
[in] | fixed_point_position | The new fixed point position |
Implements ITensorInfo.
|
overridevirtual |
Set the format of an already initialized tensor.
[in] | format | Single-plane format of the tensor. |
Implements ITensorInfo.
Referenced by arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::test::validation::FIXTURE_DATA_TEST_CASE(), and arm_compute::test::validation::validate_configuration().
|
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 291 of file TensorInfo.h.
References TensorInfo::is_resizable().
|
overridevirtual |
Set the number of channels to the specified value.
[in] | num_channels | New number of channels. |
Implements ITensorInfo.
|
overridevirtual |
Set the quantization settings (scale and offset) of the tensor.
[in] | quantization_info | QuantizationInfo containing the scale and offset |
Implements ITensorInfo.
Referenced by arm_compute::test::create_tensor(), and arm_compute::test::validation::DATA_TEST_CASE().
|
overridevirtual |
Set the shape of an already initialized tensor.
[in] | shape | New tensor shape. |
Implements ITensorInfo.
Referenced by arm_compute::test::validation::TEST_CASE().
|
inlineoverridevirtual |
Set the valid region of the tensor.
[in] | valid_region | Valid region to set. |
Implements ITensorInfo.
Definition at line 300 of file TensorInfo.h.
References TensorInfo::valid_region().
|
inlineoverridevirtual |
The strides in bytes for accessing each dimension of the tensor.
Implements ITensorInfo.
Definition at line 238 of file TensorInfo.h.
|
inlineoverridevirtual |
Size for each dimension of the tensor.
Implements ITensorInfo.
Definition at line 263 of file TensorInfo.h.
Referenced by arm_compute::test::validation::reference::hog_multi_detection(), GCAccessor::num_elements(), CLAccessor::num_elements(), GCAccessor::shape(), CLAccessor::shape(), arm_compute::test::validation::TEST_CASE(), and arm_compute::to_string().
|
inlineoverridevirtual |
Returns the total size of the tensor in bytes.
Implements ITensorInfo.
Definition at line 275 of file TensorInfo.h.
Referenced by GCAccessor::size(), CLAccessor::size(), and arm_compute::test::validation::TEST_CASE().
|
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 296 of file TensorInfo.h.
Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and TensorInfo::set_valid_region().