24.02.1
|
Simple tensor object that stores elements in a consecutive chunk of memory. More...
#include <SimpleTensor.h>
Public Types | |
using | value_type = T |
Tensor value type. More... | |
using | Buffer = std::unique_ptr< value_type[]> |
Tensor buffer pointer type. More... | |
Public Member Functions | |
SimpleTensor ()=default | |
Create an uninitialised tensor. More... | |
SimpleTensor (TensorShape shape, Format format) | |
Create an uninitialised tensor of the given shape and format . More... | |
SimpleTensor (TensorShape shape, DataType data_type, int num_channels=1, QuantizationInfo quantization_info=QuantizationInfo(), DataLayout data_layout=DataLayout::NCHW) | |
Create an uninitialised tensor of the given shape and data type. More... | |
SimpleTensor (const SimpleTensor &tensor) | |
Create a deep copy of the given tensor . More... | |
SimpleTensor & | operator= (SimpleTensor tensor) |
Create a deep copy of the given tensor . More... | |
SimpleTensor (SimpleTensor &&)=default | |
Allow instances of this class to be move constructed. More... | |
~SimpleTensor ()=default | |
Default destructor. More... | |
T & | operator[] (size_t offset) |
Return value at offset in the buffer. More... | |
const T & | operator[] (size_t offset) const |
Return constant value at offset in the buffer. More... | |
TensorShape | shape () const override |
Shape of the tensor. More... | |
size_t | element_size () const override |
Size of each element in the tensor in bytes. More... | |
size_t | size () const override |
Total size of the tensor in bytes. More... | |
Format | format () const override |
Image format of the tensor. More... | |
DataLayout | data_layout () const override |
Data layout of the tensor. More... | |
DataType | data_type () const override |
Data type of the tensor. More... | |
int | num_channels () const override |
Number of channels of the tensor. More... | |
int | num_elements () const override |
Number of elements of the tensor. More... | |
PaddingSize | padding () const override |
Available padding around the tensor. More... | |
QuantizationInfo | quantization_info () const override |
Quantization info in case of asymmetric quantized type. More... | |
SimpleTensor< T > & | quantization_info (const QuantizationInfo &qinfo) |
Set the quantization information of the tensor. More... | |
const T * | data () const |
Constant pointer to the underlying buffer. More... | |
T * | data () |
Pointer to the underlying buffer. More... | |
const void * | operator() (const Coordinates &coord) const override |
Read only access to the specified element. More... | |
void * | operator() (const Coordinates &coord) override |
Access to the specified element. More... | |
Public Member Functions inherited from IAccessor | |
virtual | ~IAccessor ()=default |
Virtual destructor. More... | |
Friends | |
class | RawTensor |
template<typename U > | |
void | swap (SimpleTensor< U > &tensor1, SimpleTensor< U > &tensor2) |
Swaps the content of the provided tensors. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
SimpleTensor< T > | convert_to_asymmetric (const SimpleTensor< float > &src, const QuantizationInfo &quantization_info) |
Convert float simple tensor into quantized using specified quantization information. More... | |
template<typename T > | |
SimpleTensor< T > | convert_to_symmetric (const SimpleTensor< float > &src, const QuantizationInfo &quantization_info) |
Convert float simple tensor into quantized using specified quantization information. More... | |
Simple tensor object that stores elements in a consecutive chunk of memory.
It can be created by either loading an image from a file which also initialises the content of the tensor or by explcitly specifying the size. The latter leaves the content uninitialised.
Furthermore, the class provides methods to convert the tensor's values into different image format.
Definition at line 58 of file SimpleTensor.h.
using Buffer = std::unique_ptr<value_type[]> |
Tensor buffer pointer type.
Definition at line 105 of file SimpleTensor.h.
using value_type = T |
Tensor value type.
Definition at line 103 of file SimpleTensor.h.
|
default |
Create an uninitialised tensor.
SimpleTensor | ( | TensorShape | shape, |
Format | format | ||
) |
Create an uninitialised tensor of the given shape
and format
.
[in] | shape | Shape of the new raw tensor. |
[in] | format | Format of the new raw tensor. |
Definition at line 271 of file SimpleTensor.h.
SimpleTensor | ( | TensorShape | shape, |
DataType | data_type, | ||
int | num_channels = 1 , |
||
QuantizationInfo | quantization_info = QuantizationInfo() , |
||
DataLayout | data_layout = DataLayout::NCHW |
||
) |
Create an uninitialised tensor of the given shape
and data
type.
[in] | shape | Shape of the new raw tensor. |
[in] | data_type | Data type of the new raw tensor. |
[in] | num_channels | (Optional) Number of channels (default = 1). |
[in] | quantization_info | (Optional) Quantization info for asymmetric quantization (default = empty). |
[in] | data_layout | (Optional) Data layout of the tensor (default = NCHW). |
Definition at line 283 of file SimpleTensor.h.
SimpleTensor | ( | const SimpleTensor< T > & | tensor | ) |
Create a deep copy of the given tensor
.
[in] | tensor | To be copied tensor. |
Definition at line 295 of file SimpleTensor.h.
|
default |
Allow instances of this class to be move constructed.
|
default |
Default destructor.
T* data | ( | ) |
Pointer to the underlying buffer.
T * data |
Constant pointer to the underlying buffer.
Definition at line 436 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::bounding_box_transform(), arm_compute::test::validation::reference::compute_all_anchors(), arm_compute::test::convolution_3d::detail::convolution3d(), arm_compute::test::copy_tensor(), arm_compute::test::validation::reference::crop_and_resize(), AssetsLibrary::fill(), arm_compute::test::validation::reference::fuse_batch_normalization_conv_layer(), arm_compute::test::validation::reference::fuse_batch_normalization_dwc_layer(), arm_compute::test::validation::reference::gather(), arm_compute::test::validation::reference::gemm_interleave_4x4(), arm_compute::test::validation::reference::gemm_transpose_1xW(), arm_compute::test::validation::reference::mean_and_standard_deviation(), arm_compute::test::validation::reference::non_max_suppression(), arm_compute::test::validation::reference::prior_box_layer(), arm_compute::test::validation::reference::roi_align_layer(), arm_compute::test::validation::reference::roi_pool_layer(), and arm_compute::test::validation::reference::select().
|
overridevirtual |
Data layout of the tensor.
Implements IAccessor.
Definition at line 367 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::deconvolution_layer(), arm_compute::test::validation::reference::winograd_filter_transform(), and arm_compute::test::validation::reference::winograd_input_transform().
|
overridevirtual |
Data type of the tensor.
Implements IAccessor.
Definition at line 373 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::bitwise_and(), arm_compute::test::validation::reference::bitwise_or(), arm_compute::test::validation::reference::bitwise_xor(), arm_compute::test::validation::reference::bounding_box_transform(), arm_compute::test::validation::reference::compare(), arm_compute::test::validation::reference::compute_all_anchors(), arm_compute::test::validation::reference::deconvolution_layer(), AssetsLibrary::fill(), arm_compute::test::validation::reference::gemm(), arm_compute::test::validation::reference::gemm_mixed_precision(), arm_compute::test::validation::reference::gemm_reshape_lhs_matrix(), arm_compute::test::validation::reference::gemm_reshape_rhs_matrix(), arm_compute::test::validation::reference::gemm_transpose_1xW(), arm_compute::test::validation::reference::logical_and(), arm_compute::test::validation::reference::logical_or(), arm_compute::test::validation::reference::pixel_wise_multiplication(), arm_compute::test::validation::reference::prior_box_layer(), arm_compute::test::validation::reference::scale_core(), arm_compute::test::validation::reference::select(), arm_compute::test::validation::validate(), arm_compute::test::validation::validate_wrap(), arm_compute::test::validation::reference::winograd_filter_transform(), arm_compute::test::validation::reference::winograd_input_transform(), and arm_compute::test::validation::reference::winograd_output_transform().
|
overridevirtual |
Size of each element in the tensor in bytes.
Implements IAccessor.
Definition at line 335 of file SimpleTensor.h.
Referenced by AssetsLibrary::fill(), RawTensor::RawTensor(), arm_compute::test::validation::validate(), and arm_compute::test::validation::validate_wrap().
|
overridevirtual |
Image format of the tensor.
Implements IAccessor.
Definition at line 361 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::validate(), and arm_compute::test::validation::validate_wrap().
|
overridevirtual |
Number of channels of the tensor.
Implements IAccessor.
Definition at line 386 of file SimpleTensor.h.
Referenced by RawTensor::RawTensor(), arm_compute::test::validation::validate(), and arm_compute::test::validation::validate_wrap().
|
overridevirtual |
Number of elements of the tensor.
Implements IAccessor.
Definition at line 424 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::absolute_difference(), arm_compute::test::validation::reference::bitwise_and(), arm_compute::test::validation::reference::bitwise_or(), arm_compute::test::validation::reference::bitwise_xor(), arm_compute::test::copy_tensor(), arm_compute::test::validation::reference::crop_and_resize(), arm_compute::test::validation::reference::mean_and_standard_deviation(), RawTensor::RawTensor(), arm_compute::test::validation::reference::reverse(), arm_compute::test::validation::reference::scale_core(), arm_compute::test::validation::reference::select(), arm_compute::test::validation::validate(), and arm_compute::test::validation::validate_wrap().
|
overridevirtual |
Read only access to the specified element.
[in] | coord | Coordinates of the desired element. |
Implements IAccessor.
Definition at line 448 of file SimpleTensor.h.
|
overridevirtual |
Access to the specified element.
[in] | coord | Coordinates of the desired element. |
Implements IAccessor.
Definition at line 454 of file SimpleTensor.h.
SimpleTensor< T > & operator= | ( | SimpleTensor< T > | tensor | ) |
Create a deep copy of the given tensor
.
[in] | tensor | To be copied tensor. |
Definition at line 309 of file SimpleTensor.h.
T & operator[] | ( | size_t | offset | ) |
Return value at offset
in the buffer.
[in] | offset | Offset within the buffer. |
Definition at line 317 of file SimpleTensor.h.
const T & operator[] | ( | size_t | offset | ) | const |
Return constant value at offset
in the buffer.
[in] | offset | Offset within the buffer. |
Definition at line 323 of file SimpleTensor.h.
|
overridevirtual |
Available padding around the tensor.
Implements IAccessor.
Definition at line 430 of file SimpleTensor.h.
|
overridevirtual |
Quantization info in case of asymmetric quantized type.
Implements IAccessor.
Definition at line 341 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::bounding_box_transform(), arm_compute::test::validation::reference::compute_all_anchors(), arm_compute::test::validation::reference::deconvolution_layer(), and arm_compute::test::validation::reference::qlstm_layer_normalization().
SimpleTensor< T > & quantization_info | ( | const QuantizationInfo & | qinfo | ) |
Set the quantization information of the tensor.
This function does not have any effect on the raw quantized data of the tensor. It simply changes the quantization information, hence changes the dequantized values.
Definition at line 347 of file SimpleTensor.h.
|
overridevirtual |
Shape of the tensor.
Implements IAccessor.
Definition at line 329 of file SimpleTensor.h.
Referenced by arm_compute::test::validation::reference::absolute_difference(), arm_compute::test::validation::reference::arithmetic_division(), arm_compute::test::validation::reference::arithmetic_operation(), arm_compute::test::validation::reference::bitwise_and(), arm_compute::test::validation::reference::bitwise_or(), arm_compute::test::validation::reference::bitwise_xor(), arm_compute::test::validation::reference::bounding_box_transform(), arm_compute::test::colorconvert_helper::detail::colorconvert_rgb_to_iyuv(), arm_compute::test::colorconvert_helper::detail::colorconvert_rgb_to_nv12(), arm_compute::test::validation::reference::compare(), arm_compute::test::validation::reference::compute_all_anchors(), arm_compute::test::validation::reference::conv3d(), arm_compute::test::validation::reference::convolution_layer_nchw(), arm_compute::test::validation::reference::crop_and_resize(), arm_compute::test::validation::reference::deconvolution_layer(), AssetsLibrary::fill(), arm_compute::test::validation::reference::fully_connected_layer(), arm_compute::test::validation::reference::gather(), arm_compute::test::validation::reference::gemm(), arm_compute::test::validation::reference::gemm_interleave_4x4(), arm_compute::test::validation::reference::gemm_interleave_blocked(), arm_compute::test::validation::reference::gemm_mixed_precision(), arm_compute::test::validation::reference::gemm_reshape_lhs_matrix(), arm_compute::test::validation::reference::gemm_reshape_rhs_matrix(), arm_compute::test::validation::reference::gemm_transpose_1xW(), arm_compute::test::validation::reference::gemmlowp_matrix_multiply_core(), arm_compute::test::validation::reference::gemmlowp_quantize_down_scale(), arm_compute::test::validation::reference::gemmlowp_quantize_down_scale_by_fixedpoint(), arm_compute::test::validation::reference::gemmlowp_quantize_down_scale_by_float(), AssetsLibrary::get(), AssetsLibrary::get_image_shape(), arm_compute::test::validation::get_tile(), arm_compute::test::validation::reference::l2_normalize(), arm_compute::test::validation::reference::logical_and(), arm_compute::test::validation::reference::logical_or(), arm_compute::test::validation::matrix_multiply(), arm_compute::test::validation::reference::max_unpooling_layer_internal(), arm_compute::test::validation::reference::non_max_suppression(), arm_compute::test::validation::reference::pixel_wise_multiplication(), arm_compute::test::validation::reference::prior_box_layer(), arm_compute::test::validation::reference::reverse(), arm_compute::test::colorconvert_helper::detail::rgb_to_yuv_calculation(), arm_compute::test::validation::reference::roi_align_layer(), arm_compute::test::validation::reference::roi_pool_layer(), arm_compute::test::validation::reference::scale_core(), arm_compute::test::validation::reference::select(), arm_compute::test::validation::transpose_matrix(), arm_compute::test::validation::reference::unstack(), arm_compute::test::validation::validate(), arm_compute::test::validation::validate_wrap(), arm_compute::test::validation::reference::winograd_filter_transform(), arm_compute::test::validation::reference::winograd_input_transform(), arm_compute::test::validation::reference::winograd_output_transform(), and arm_compute::test::validation::zeros().
|
overridevirtual |
Total size of the tensor in bytes.
Implements IAccessor.
Definition at line 354 of file SimpleTensor.h.
Referenced by AssetsLibrary::fill(), and arm_compute::test::validation::reference::weights_reshape().
|
related |
Convert float simple tensor into quantized using specified quantization information.
[in] | src | Float tensor. |
[in] | quantization_info | Quantification information. |
Definition at line 86 of file Helpers.cpp.
|
related |
Convert float simple tensor into quantized using specified quantization information.
[in] | src | Float tensor. |
[in] | quantization_info | Quantification information. |
Definition at line 134 of file Helpers.cpp.
|
friend |
Definition at line 107 of file SimpleTensor.h.
|
friend |