ARM Compute Library
17.04
|
Store the tensor's metadata. More...
#include <TensorInfo.h>
Public Member Functions | |
TensorInfo () | |
Default constructor. More... | |
virtual | ~TensorInfo ()=default |
Default destructor. 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 (unsigned int width, unsigned int height, Format format) | |
2D tensor constructor More... | |
TensorInfo (const TensorShape &tensor_shape, Format format) | |
Constructor. More... | |
TensorInfo (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, size_t fixed_point_pos=0) | |
Constructor. More... | |
TensorInfo (const HOGInfo &hog_info, unsigned int width, unsigned int height) | |
Constructor. 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 (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, size_t fixed_point_pos=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, size_t fixed_point_pos=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, size_t fixed_point_pos=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... | |
bool | auto_padding () |
Update the offset to the first element and the strides to automatically computed values. More... | |
bool | extend_padding (const PaddingSize &padding) |
Update the offset to the first element, the strides and the total size. More... | |
void | set_format (Format format) |
Set the format of an already initialized tensor. More... | |
size_t | dimension (size_t index) const |
Return the size of the requested dimension. More... | |
const Strides & | strides_in_bytes () const |
The strides in bytes for accessing each dimension of the tensor. More... | |
size_t | offset_first_element_in_bytes () const |
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 |
The offset in bytes from the beginning of the memory allocation to access the element at position (x, y, z ...) More... | |
size_t | fixed_point_pos () const |
Fixed point position used when the tensor data type is S8, S16 or S32. More... | |
size_t | element_size () const |
Element size in bytes calculated as data_size() * num_channels. More... | |
size_t | num_dimensions () const |
The number of dimensions of the tensor (rank) More... | |
size_t | num_channels () const |
The number of channels for each tensor element. More... | |
const TensorShape & | tensor_shape () const |
Size for each dimension of the tensor. More... | |
DataType | data_type () const |
Data type used for each element of the tensor. More... | |
Format | format () const |
Colour format of the image. More... | |
size_t | total_size () const |
Returns the total size of the tensor in bytes. More... | |
PaddingSize | padding () const |
Padding of tensor. More... | |
bool | has_padding () const |
Checks if the tensor has been allocated with padding or not. More... | |
bool | is_resizable () const |
Flag indicating whether the size of the tensor can be changed. More... | |
void | set_is_resizable (bool is_resizable) |
Set the flag whether the tensor size can be changed. More... | |
ValidRegion | valid_region () const |
Valid region of the tensor. More... | |
void | set_valid_region (ValidRegion valid_region) |
Set the valid region of the tensor. More... | |
Store the tensor's metadata.
Definition at line 40 of file TensorInfo.h.
TensorInfo | ( | ) |
Default constructor.
|
virtualdefault |
Default destructor.
|
default |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be move constructed.
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 | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
size_t | fixed_point_pos = 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_pos | (Optional) It specifies the fixed point position when the tensor data type is INT8, INT16 or INT32. (Default = 0) If 0, calculations are performed in integer math |
TensorInfo | ( | const HOGInfo & | hog_info, |
unsigned int | width, | ||
unsigned int | height | ||
) |
bool auto_padding | ( | ) |
Update the offset to the first element and the strides to automatically computed values.
|
inline |
Data type used for each element of the tensor.
Definition at line 263 of file TensorInfo.h.
Referenced by arm_compute::error_on_data_type_not_in(), and arm_compute::error_on_mismatching_data_types().
|
inline |
Return the size of the requested dimension.
[in] | index | Index of the dimension |
Definition at line 190 of file TensorInfo.h.
Referenced by arm_compute::have_different_shapes(), main_cl_events(), main_neoncl_scale_median_gaussian(), and Window::use_tensor_dimensions().
|
inline |
Element size in bytes calculated as data_size() * num_channels.
Definition at line 231 of file TensorInfo.h.
References arm_compute::data_size_from_type().
Referenced by arm_compute::compute_strides().
bool extend_padding | ( | const PaddingSize & | padding | ) |
Update the offset to the first element, the strides and the total size.
[in] | padding | Padding around the XY plane in number of elements. |
|
inline |
Fixed point position used when the tensor data type is S8, S16 or S32.
Definition at line 223 of file TensorInfo.h.
|
inline |
Colour format of the image.
Definition at line 271 of file TensorInfo.h.
|
inline |
Checks if the tensor has been allocated with padding or not.
Definition at line 295 of file TensorInfo.h.
References BorderSize::empty().
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 | ( | const TensorShape & | tensor_shape, |
size_t | num_channels, | ||
DataType | data_type, | ||
size_t | fixed_point_pos = 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_pos | (Optional) Fixed point position when the tensor data type is INT8, INT16 or INT32 (default = 0). If 0, calculations are performed in integer arithmetic. |
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, | ||
size_t | fixed_point_pos = 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_pos | (Optional) Fixed point position when the tensor data type is INT8, INT16 or INT32 (default = 0). If 0, calculations are performed in integer arithmetic. |
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, | ||
size_t | fixed_point_pos = 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_pos | (Optional) It specifies the fixed point position when the tensor data type is INT8, INT16 or INT32. (Default = 0) If 0, calculations are performed in integer math |
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.
|
inline |
Flag indicating whether the size of the tensor can be changed.
Definition at line 303 of file TensorInfo.h.
Referenced by TensorInfo::set_is_resizable().
|
inline |
The number of channels for each tensor element.
Definition at line 247 of file TensorInfo.h.
Referenced by arm_compute::error_on_data_type_channel_not_in().
|
inline |
The number of dimensions of the tensor (rank)
Definition at line 239 of file TensorInfo.h.
References Dimensions< T >::num_dimensions().
Referenced by arm_compute::compute_strides(), and Window::use_tensor_dimensions().
size_t offset_element_in_bytes | ( | const Coordinates & | pos | ) | const |
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 |
Referenced by test_helpers::draw_detection_rectangle(), TensorInfo::offset_first_element_in_bytes(), and ITensor::ptr_to_element().
|
inline |
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
Definition at line 207 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.
|
inline |
void set_format | ( | Format | format | ) |
Set the format of an already initialized tensor.
[in] | format | Single-plane format of the tensor. |
|
inline |
Set the flag whether the tensor size can be changed.
Definition at line 308 of file TensorInfo.h.
References TensorInfo::is_resizable().
|
inline |
Set the valid region of the tensor.
Definition at line 321 of file TensorInfo.h.
|
inline |
The strides in bytes for accessing each dimension of the tensor.
Definition at line 198 of file TensorInfo.h.
Referenced by arm_compute::colorconvert_iyuv_to_rgb(), arm_compute::colorconvert_nv12_to_rgb(), and test_helpers::draw_detection_rectangle().
|
inline |
Size for each dimension of the tensor.
Definition at line 255 of file TensorInfo.h.
Referenced by arm_compute::compute_strides().
|
inline |
Returns the total size of the tensor in bytes.
Definition at line 279 of file TensorInfo.h.
|
inline |
Valid region of the tensor.
All elements in the valid region have defined values, i.e. are not undefined.
Definition at line 316 of file TensorInfo.h.