Compute Library
 20.02.1
TensorInfo Class Referencefinal

Store the tensor's metadata. More...

#include <TensorInfo.h>

Collaboration diagram for TensorInfo:
[legend]

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...
 
TensorInfooperator= (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...
 
TensorInfooperator= (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)
 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)
 Constructor. More...
 
 TensorInfo (const TensorShape &tensor_shape, size_t num_channels, DataType data_type, DataLayout data_layout)
 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)
 Initialize the tensor info with just a format. More...
 
void init (const TensorShape &tensor_shape, size_t num_channels, DataType data_type)
 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)
 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)
 Initialize the metadata structure for the given tensor shape, number of channels and data type. 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< ITensorInfoclone () const override
 Provide a clone of the current object of class T. More...
 
ITensorInfoset_data_type (DataType data_type) override
 Set the data type to the specified value. More...
 
ITensorInfoset_num_channels (int num_channels) override
 Set the number of channels to the specified value. More...
 
ITensorInfoset_format (Format format) override
 Set the format of an already initialized tensor. More...
 
ITensorInfoset_tensor_shape (const TensorShape &shape) override
 Set the shape of an already initialized tensor. More...
 
ITensorInfoset_quantization_info (const QuantizationInfo &quantization_info) override
 Set the quantization settings (scale and offset) of the tensor. More...
 
ITensorInfoset_data_layout (const DataLayout &data_layout) override
 Set the data layout of the tensor. More...
 
ITensorInforeset_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 Stridesstrides_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 TensorShapetensor_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...
 
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...
 
ITensorInfoset_is_resizable (bool is_resizable) override
 Set the flag whether the tensor size can be changed. More...
 
ITensorInfoset_is_dynamic (bool is_dynamic) override
 Set the flag whether the tensor size is dynamic. 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, ValidRegionbroadcast_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...
 

Detailed Description

Store the tensor's metadata.

Definition at line 45 of file TensorInfo.h.

Constructor & Destructor Documentation

◆ TensorInfo() [1/12]

Default constructor.

Definition at line 35 of file TensorInfo.cpp.

36  : _total_size(0), _offset_first_element_in_bytes(0), _strides_in_bytes(), _num_channels(0), _tensor_shape(), _data_type(DataType::UNKNOWN), _format(Format::UNKNOWN), _is_resizable{ true }, _is_dynamic{ false },
37  _valid_region{ Coordinates(), _tensor_shape }, _padding{ 0 }, _quantization_info(), _data_layout(DataLayout::NCHW)
38 {
39 }
Coordinates of an item.
Definition: Coordinates.h:37
Num samples, channels, height, width.

References arm_compute::UNKNOWN.

◆ ~TensorInfo()

~TensorInfo ( )
default

Default destructor.

◆ TensorInfo() [2/12]

TensorInfo ( const ITensorInfo info)

Allow instances of this class to be copy constructed.

Definition at line 41 of file TensorInfo.cpp.

42  : TensorInfo()
43 {
44  _total_size = info.total_size();
45  _offset_first_element_in_bytes = info.offset_first_element_in_bytes();
46  _strides_in_bytes = info.strides_in_bytes();
47  _num_channels = info.num_channels();
48  _tensor_shape = info.tensor_shape();
49  _data_type = info.data_type();
50  _format = info.format();
51  _is_resizable = info.is_resizable();
52  _is_dynamic = info.is_dynamic();
53  _valid_region = info.valid_region();
54  _padding = info.padding();
55  _quantization_info = info.quantization_info();
56  _data_layout = info.data_layout();
57 }
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35

References arm_compute::test::validation::info.

◆ TensorInfo() [3/12]

TensorInfo ( const TensorInfo )
default

Allow instances of this class to be copy constructed.

◆ TensorInfo() [4/12]

TensorInfo ( TensorInfo &&  )
default

Allow instances of this class to be move constructed.

◆ TensorInfo() [5/12]

TensorInfo ( Format  format)

Construct a tensor info with a format.

Can be used for automatic derivation of the shape by the function.

Parameters
[in]formatFormat of the tensor.

Definition at line 59 of file TensorInfo.cpp.

61 {
62 }
Shape of a tensor.
Definition: TensorShape.h:39
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35

◆ TensorInfo() [6/12]

TensorInfo ( unsigned int  width,
unsigned int  height,
Format  format 
)

2D tensor constructor

Parameters
[in]widthWidth of the 2D tensor
[in]heightHeight of the 2D tensor
[in]formatSingle plane format of the tensor.

Definition at line 64 of file TensorInfo.cpp.

65  : TensorInfo(TensorShape(width, height), format)
66 {
67 }
Shape of a tensor.
Definition: TensorShape.h:39
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35

◆ TensorInfo() [7/12]

TensorInfo ( const TensorShape tensor_shape,
Format  format 
)

Constructor.

Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements.
[in]formatSingle plane format of the tensor.

Definition at line 69 of file TensorInfo.cpp.

70  : TensorInfo()
71 {
73 }
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References TensorInfo::format(), TensorInfo::init(), and TensorInfo::tensor_shape().

◆ TensorInfo() [8/12]

TensorInfo ( size_t  num_channels,
DataType  data_type 
)

Construct a tensor info with a data type and number of channels.

Can be used for automatic derivation of the shape by the function.

Parameters
[in]num_channelsIt indicates the number of channels for each tensor element
[in]data_typeData type to use for each tensor element

Definition at line 75 of file TensorInfo.cpp.

76  : TensorInfo()
77 {
79 }
Shape of a tensor.
Definition: TensorShape.h:39
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35

References TensorInfo::data_type(), TensorInfo::init(), and TensorInfo::num_channels().

◆ TensorInfo() [9/12]

TensorInfo ( const TensorShape tensor_shape,
size_t  num_channels,
DataType  data_type 
)

Constructor.

Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements.
[in]num_channelsIt indicates the number of channels for each tensor element
[in]data_typeData type to use for each tensor element

Definition at line 81 of file TensorInfo.cpp.

82  : TensorInfo()
83 {
85 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References TensorInfo::data_type(), TensorInfo::init(), TensorInfo::num_channels(), and TensorInfo::tensor_shape().

◆ TensorInfo() [10/12]

TensorInfo ( const TensorShape tensor_shape,
size_t  num_channels,
DataType  data_type,
DataLayout  data_layout 
)

Constructor.

Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements.
[in]num_channelsIt indicates the number of channels for each tensor element
[in]data_typeData type to use for each tensor element
[in]data_layoutThe data layout setting for the tensor data.

Definition at line 94 of file TensorInfo.cpp.

95  : TensorInfo()
96 {
98  _data_layout = data_layout;
99 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
DataLayout data_layout() const override
Get the data layout of the tensor.
Definition: TensorInfo.h:315
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References TensorInfo::data_layout(), TensorInfo::data_type(), TensorInfo::init(), TensorInfo::num_channels(), and TensorInfo::tensor_shape().

◆ TensorInfo() [11/12]

TensorInfo ( const TensorShape tensor_shape,
size_t  num_channels,
DataType  data_type,
QuantizationInfo  quantization_info 
)

Constructor.

Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements.
[in]num_channelsIt indicates the number of channels for each tensor element
[in]data_typeData type to use for each tensor element
[in]quantization_infoThe quantization settings for the tensor data.

Definition at line 87 of file TensorInfo.cpp.

88  : TensorInfo()
89 {
91  _quantization_info = std::move(quantization_info);
92 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:311
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References TensorInfo::data_type(), TensorInfo::init(), TensorInfo::num_channels(), TensorInfo::quantization_info(), and TensorInfo::tensor_shape().

◆ TensorInfo() [12/12]

TensorInfo ( const HOGInfo hog_info,
unsigned int  width,
unsigned int  height 
)

Constructor.

Parameters
[in]hog_infoHOG's metadata used to allocate normalized HOG space
[in]widthWidth of the 2D tensor where the HOG descriptor will be computed on
[in]heightHeight of the 2D tensor where the HOG descriptor will be computed on

Definition at line 101 of file TensorInfo.cpp.

102  : TensorInfo()
103 {
104  init(hog_info, width, height);
105 }
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:35

References TensorInfo::init().

Member Function Documentation

◆ auto_padding()

bool auto_padding ( )
overridevirtual

Update the offset to the first element and the strides to automatically computed values.

Note
The padding used by this method is really conservative so that the tensor can be used for most functions.
Returns
True if the strides or the offset to the first element have changed.

Implements ITensorInfo.

Definition at line 222 of file TensorInfo.cpp.

223 {
224  ARM_COMPUTE_ERROR_ON(!_is_resizable);
225 
226  // Some kernels compute 32 elements at the time, worst case scenario they
227  // will read 32 values after the last element
228  const size_t extra_pad_x = _tensor_shape.num_dimensions() < 1 ? 0 : 32;
229  const size_t pad_x = _tensor_shape.num_dimensions() < 1 ? 0 : 4;
230  const size_t pad_y = _tensor_shape.num_dimensions() < 2 ? 0 : 4;
231 
232  return extend_padding(PaddingSize(pad_y, pad_x + extra_pad_x, pad_y, pad_x));
233 }
bool extend_padding(const PaddingSize &padding) override
Update the offset to the first element, the strides and the total size.
Definition: TensorInfo.cpp:279
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
BorderSize PaddingSize
Container for 2D padding size.
Definition: Types.h:356
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122

References ARM_COMPUTE_ERROR_ON, TensorInfo::extend_padding(), and Dimensions< T >::num_dimensions().

Referenced by TensorInfo::init_auto_padding().

◆ clone()

std::unique_ptr< ITensorInfo > clone ( ) const
overridevirtual

Provide a clone of the current object of class T.

Returns
Clone object of class T

Implements ICloneable< ITensorInfo >.

Definition at line 314 of file TensorInfo.cpp.

315 {
316  return support::cpp14::make_unique<TensorInfo>(*this);
317 }

Referenced by CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), NEDeconvolutionLayer::configure(), CPPSplit< CLSlice, ICLTensor >::validate(), CLWinogradConvolutionLayer::validate(), NEWinogradConvolutionLayer::validate(), NEGEMM::validate(), and CLGEMMDeconvolutionLayer::validate().

◆ data_layout()

DataLayout data_layout ( ) const
inlineoverridevirtual

Get the data layout of the tensor.

Returns
A DataLayout containing the layout data information.

Implements ITensorInfo.

Definition at line 315 of file TensorInfo.h.

316  {
317  return _data_layout;
318  }

Referenced by arm_compute::calculate_valid_region_scale(), NEDirectConvolutionLayerKernel::configure(), CLDirectDeconvolutionLayer::configure(), GCAccessor::data_layout(), CLAccessor::data_layout(), TensorInfo::set_data_layout(), and TensorInfo::TensorInfo().

◆ data_type()

◆ dimension() [1/2]

◆ dimension() [2/2]

size_t dimension ( DataLayoutDimension  dimension) const
inlineoverridevirtual

Return the size of the requested data layout dimension.

Parameters
[in]dimensionDataLayoutDimension of the dimension
Returns
Dimension of the requested dimension

Implements ITensorInfo.

Definition at line 236 of file TensorInfo.h.

237  {
238  return get_data_layout_dimension_index(_data_layout, dimension);
239  }
size_t dimension(size_t index) const override
Return the size of the requested dimension.
Definition: TensorInfo.h:232
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327

References TensorInfo::dimension(), and arm_compute::get_data_layout_dimension_index().

◆ element_size()

size_t element_size ( ) const
inlineoverridevirtual

Element size in bytes calculated as data_size() * num_channels()

Returns
The size of one element in bytes

Implements ITensorInfo.

Definition at line 249 of file TensorInfo.h.

250  {
251  return data_size_from_type(_data_type) * _num_channels;
252  }
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
Definition: Utils.h:109

References arm_compute::data_size_from_type().

Referenced by ITensor::copy_from(), GCAccessor::element_size(), and CLAccessor::element_size().

◆ extend_padding()

bool extend_padding ( const PaddingSize padding)
overridevirtual

Update the offset to the first element, the strides and the total size.

Note
This function can only increase the offset, strides and total size.
Parameters
[in]paddingPadding around the XY plane in number of elements.
Returns
True if the strides, offset and total size have changed.

Implements ITensorInfo.

Definition at line 279 of file TensorInfo.cpp.

280 {
281  ARM_COMPUTE_ERROR_ON(!_is_resizable);
282 
283  bool updated = false;
284 
285  if(padding.top > _padding.top)
286  {
287  _padding.top = padding.top;
288  updated = true;
289  }
290 
291  if(padding.right > _padding.right)
292  {
293  _padding.right = padding.right;
294  updated = true;
295  }
296 
297  if(padding.bottom > _padding.bottom)
298  {
299  _padding.bottom = padding.bottom;
300  updated = true;
301  }
302 
303  if(padding.left > _padding.left)
304  {
305  _padding.left = padding.left;
306  updated = true;
307  }
308 
309  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
310 
311  return updated;
312 }
unsigned int top
top of the border
Definition: Types.h:349
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
unsigned int bottom
bottom of the border
Definition: Types.h:351
PaddingSize padding() const override
Padding of tensor.
Definition: TensorInfo.h:277
unsigned int left
left of the border
Definition: Types.h:352
unsigned int right
right of the border
Definition: Types.h:350

References ARM_COMPUTE_ERROR_ON, BorderSize::bottom, BorderSize::left, TensorInfo::padding(), BorderSize::right, and BorderSize::top.

Referenced by TensorInfo::auto_padding().

◆ format()

Format format ( ) const
inlineoverridevirtual

Colour format of the image.

Returns
Colour format of the image

Implements ITensorInfo.

Definition at line 269 of file TensorInfo.h.

270  {
271  return _format;
272  }

Referenced by GCAccessor::format(), CLAccessor::format(), TensorAllocator::init(), TensorInfo::init(), TensorInfo::init_auto_padding(), TensorInfo::set_format(), and TensorInfo::TensorInfo().

◆ has_padding()

bool has_padding ( ) const
inlineoverridevirtual

Checks if the tensor has been allocated with padding or not.

Returns
True if padding is allocated in the tensor, otherwise false.

Implements ITensorInfo.

Definition at line 281 of file TensorInfo.h.

282  {
283  return !_padding.empty();
284  }
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:296

References BorderSize::empty().

◆ init() [1/7]

void init ( Format  format)

Initialize the tensor info with just a format.

Can be used for automatic derivation of the shape by the function.

Parameters
[in]formatSingle plane format of the tensor.

Definition at line 107 of file TensorInfo.cpp.

108 {
109  init(TensorShape(), format);
110 }
Shape of a tensor.
Definition: TensorShape.h:39
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107

References TensorInfo::format().

Referenced by CLSoftmaxLayerGeneric< IS_LOG >::configure(), CLCannyEdge::configure(), NEWinogradConvolutionLayer::configure(), NECannyEdge::configure(), NEHarrisCorners::configure(), TensorAllocator::init(), TensorInfo::init(), and TensorInfo::TensorInfo().

◆ init() [2/7]

void init ( const TensorShape tensor_shape,
Format  format 
)

Initialize the metadata structure with the given parameters.

Parameters
[in]tensor_shapeSize for each dimension of the tensor in number of elements.
[in]formatSingle plane format of the tensor.

Definition at line 112 of file TensorInfo.cpp.

113 {
116 
118 
119  _format = format;
120 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:482
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
Definition: Utils.h:219
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261
DataType
Available data types.
Definition: Types.h:75

References arm_compute::data_type_from_format(), TensorInfo::format(), TensorInfo::init(), TensorInfo::num_channels(), arm_compute::num_channels_from_format(), TensorInfo::tensor_shape(), and GemmTuner::type.

◆ init() [3/7]

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.

Parameters
[in]tensor_shapeSize for each dimension of the tensor in number of elements.
[in]formatSingle plane format of the tensor.
[in]strides_in_bytesStride in bytes for accessing each dimension of the tensor.
[in]offset_first_element_in_bytesOffset in bytes from the beginning of memory allocation to access the first element.
[in]total_size_in_bytesSize in bytes of the memory allocation (including the offset to the first element).

Definition at line 122 of file TensorInfo.cpp.

125 {
128 
130 
131  _format = format;
132 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:482
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
Definition: TensorInfo.h:240
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
Definition: Utils.h:219
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
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.
Definition: TensorInfo.h:244
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261
DataType
Available data types.
Definition: Types.h:75

References arm_compute::data_type_from_format(), TensorInfo::format(), TensorInfo::init(), TensorInfo::num_channels(), arm_compute::num_channels_from_format(), TensorInfo::offset_first_element_in_bytes(), TensorInfo::strides_in_bytes(), TensorInfo::tensor_shape(), and GemmTuner::type.

◆ init() [4/7]

void init ( size_t  num_channels,
DataType  data_type 
)

Initialize the tensor info with just a format.

Can be used for automatic derivation of the shape by the function.

Parameters
[in]num_channelsDesired number of channels for each tensor element.
[in]data_typeData type to use for each tensor element.

Definition at line 134 of file TensorInfo.cpp.

135 {
137 }
Shape of a tensor.
Definition: TensorShape.h:39
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107

References TensorInfo::data_type(), TensorInfo::init(), and TensorInfo::num_channels().

◆ init() [5/7]

void init ( const TensorShape tensor_shape,
size_t  num_channels,
DataType  data_type 
)

Initialize the metadata structure with the given parameters.

Parameters
[in]tensor_shapeSize for each dimension of the tensor in number of elements.
[in]num_channelsDesired number of channels for each tensor element.
[in]data_typeData type to use for each tensor element.

Definition at line 139 of file TensorInfo.cpp.

140 {
142 
143  _data_type = data_type;
144  _num_channels = num_channels;
145  _format = Format::UNKNOWN;
146 
148 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
Definition: TensorInfo.cpp:350
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References ARM_COMPUTE_ERROR_ON, TensorInfo::data_type(), TensorInfo::num_channels(), TensorInfo::set_tensor_shape(), TensorInfo::tensor_shape(), and arm_compute::UNKNOWN.

◆ init() [6/7]

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 
)

Initialize the metadata structure with the given parameters.

Parameters
[in]tensor_shapeSize for each dimension of the tensor in number of elements.
[in]num_channelsDesired number of channels for each tensor element.
[in]data_typeData type to use for each tensor element.
[in]strides_in_bytesStride in bytes for accessing each dimension of the tensor.
[in]offset_first_element_in_bytesOffset in bytes from the beginning of memory allocation to access the first element.
[in]total_size_in_bytesSize in bytes of the memory allocation (including the offset to the first element).

Definition at line 150 of file TensorInfo.cpp.

153 {
155 
156  _data_type = data_type;
157  _num_channels = num_channels;
158  _format = Format::UNKNOWN;
159  _tensor_shape = tensor_shape;
160  _offset_first_element_in_bytes = offset_first_element_in_bytes;
161  _strides_in_bytes = strides_in_bytes;
162  _total_size = total_size_in_bytes;
163 
164  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
165 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
Definition: TensorInfo.h:240
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
Coordinates of an item.
Definition: Coordinates.h:37
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.
Definition: TensorInfo.h:244
Container for valid region of a window.
Definition: Types.h:184
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References ARM_COMPUTE_ERROR_ON, TensorInfo::data_type(), TensorInfo::num_channels(), TensorInfo::offset_first_element_in_bytes(), TensorInfo::strides_in_bytes(), TensorInfo::tensor_shape(), and arm_compute::UNKNOWN.

◆ init() [7/7]

void init ( const HOGInfo hog_info,
unsigned int  width,
unsigned int  height 
)

Initialize the metadata structure for the given HOG's metadata.

Parameters
[in]hog_infoHOG's metadata used to allocate normalized HOG space
[in]widthWidth of the 2D tensor where the HOG descriptor will be computed on
[in]heightHeight of the 2D tensor where the HOG descriptor will be computed on

Definition at line 167 of file TensorInfo.cpp.

168 {
169  // Number of cells for each block
170  const Size2D num_cells_per_block = hog_info.num_cells_per_block();
171 
172  // Tensor Size = (Number of horizontal block positions) * (Number of vertical block positions)
173  const Size2D num_block_positions_per_img = hog_info.num_block_positions_per_image(Size2D(width, height));
174 
175  // Number of tensor channels = (Number of cells per block) * (Number of bins per cell)
176  const size_t num_channels = num_cells_per_block.area() * hog_info.num_bins();
177 
178  init(TensorShape(num_block_positions_per_img.width, num_block_positions_per_img.height), num_channels, DataType::F32);
179 }
size_t num_bins() const
The number of histogram bins for each cell.
Definition: HOGInfo.cpp:111
Shape of a tensor.
Definition: TensorShape.h:39
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
1 channel, 1 F32 per channel
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
Size2D num_cells_per_block() const
Calculates the number of cells for each block.
Definition: HOGInfo.cpp:67
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:107
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Size2D num_block_positions_per_image(const Size2D &image_size) const
Calculates the number of block positions for the given image size.
Definition: HOGInfo.cpp:83
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
size_t area() const
The area of the image or rectangle calculated as (width * height)
Definition: Size2D.h:53

References Size2D::area(), arm_compute::F32, Size2D::height, TensorInfo::init(), HOGInfo::num_bins(), HOGInfo::num_block_positions_per_image(), HOGInfo::num_cells_per_block(), TensorInfo::num_channels(), and Size2D::width.

◆ init_auto_padding() [1/3]

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)

Note
The padding used by this method is really conservative so that the tensor can be used for most functions.
Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements
[in]formatSingle plane format of the image.
Returns
Total allocation size including padding in bytes.

Definition at line 181 of file TensorInfo.cpp.

182 {
186 
187  _format = format;
188 
189  return total_size;
190 }
size_t init_auto_padding(const TensorShape &tensor_shape, Format format)
Initialize the metadata structure for the given tensor shape and single-plane format,...
Definition: TensorInfo.cpp:181
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:482
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
size_t total_size() const override
Returns the total size of the tensor in bytes.
Definition: TensorInfo.h:273
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
Definition: Utils.h:219
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261
DataType
Available data types.
Definition: Types.h:75

References arm_compute::data_type_from_format(), TensorInfo::format(), TensorInfo::num_channels(), arm_compute::num_channels_from_format(), TensorInfo::tensor_shape(), TensorInfo::total_size(), and GemmTuner::type.

◆ init_auto_padding() [2/3]

size_t init_auto_padding ( const TensorShape tensor_shape,
size_t  num_channels,
DataType  data_type 
)

Initialize the metadata structure for the given tensor shape, number of channels and data type.

(Padding is automatically calculated)

Note
The padding used by this method is really conservative so that the tensor can be used for most functions.
Parameters
[in]tensor_shapeIt specifies the size for each dimension of the tensor in number of elements
[in]num_channelsIt indicates the number of channels for each tensor element
[in]data_typeData type to use for each tensor element
Returns
Total allocation size including padding in bytes.

Definition at line 192 of file TensorInfo.cpp.

193 {
195 
196  _data_type = data_type;
197  _num_channels = num_channels;
198  _format = Format::UNKNOWN;
199  _tensor_shape = tensor_shape;
200 
201  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
202 
203  auto_padding();
204 
205  return _total_size;
206 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
bool auto_padding() override
Update the offset to the first element and the strides to automatically computed values.
Definition: TensorInfo.cpp:222
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
Coordinates of an item.
Definition: Coordinates.h:37
Container for valid region of a window.
Definition: Types.h:184
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References ARM_COMPUTE_ERROR_ON, TensorInfo::auto_padding(), TensorInfo::data_type(), TensorInfo::num_channels(), TensorInfo::tensor_shape(), and arm_compute::UNKNOWN.

◆ init_auto_padding() [3/3]

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.

Note
init_auto_padding will be used for the tensor initialization.
Parameters
[in]hog_infoHOG's metadata used to allocate normalized HOG space
[in]widthWidth of the 2D tensor where the HOG descriptor will be computed on
[in]heightHeight of the 2D tensor where the HOG descriptor will be computed on
Returns
Total allocation size including padding in bytes.

Definition at line 208 of file TensorInfo.cpp.

209 {
210  // Number of cells for each block
211  const Size2D num_cells_per_block = hog_info.num_cells_per_block();
212 
213  // Tensor Size = (Number of horizontal block positions) * (Number of vertical block positions)
214  const Size2D num_block_positions_per_img = hog_info.num_block_positions_per_image(Size2D(width, height));
215 
216  // Number of tensor channels = (Number of cells per block) * (Number of bins per cell)
217  const size_t num_channels = num_cells_per_block.area() * hog_info.num_bins();
218 
219  return init_auto_padding(TensorShape(num_block_positions_per_img.width, num_block_positions_per_img.height), num_channels, DataType::F32);
220 }
size_t num_bins() const
The number of histogram bins for each cell.
Definition: HOGInfo.cpp:111
Shape of a tensor.
Definition: TensorShape.h:39
size_t init_auto_padding(const TensorShape &tensor_shape, Format format)
Initialize the metadata structure for the given tensor shape and single-plane format,...
Definition: TensorInfo.cpp:181
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257
1 channel, 1 F32 per channel
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
Size2D num_cells_per_block() const
Calculates the number of cells for each block.
Definition: HOGInfo.cpp:67
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Size2D num_block_positions_per_image(const Size2D &image_size) const
Calculates the number of block positions for the given image size.
Definition: HOGInfo.cpp:83
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
size_t area() const
The area of the image or rectangle calculated as (width * height)
Definition: Size2D.h:53

References Size2D::area(), arm_compute::F32, Size2D::height, TensorInfo::init_auto_padding(), HOGInfo::num_bins(), HOGInfo::num_block_positions_per_image(), HOGInfo::num_cells_per_block(), TensorInfo::num_channels(), and Size2D::width.

Referenced by TensorInfo::init_auto_padding().

◆ is_dynamic()

bool is_dynamic ( ) const
inlineoverridevirtual

Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/function execution.

Returns
True if its dynamic else false

Implements ITensorInfo.

Definition at line 289 of file TensorInfo.h.

290  {
291  return _is_dynamic;
292  }

Referenced by TensorInfo::set_is_dynamic().

◆ is_resizable()

bool is_resizable ( ) const
inlineoverridevirtual

Flag indicating whether the size of the tensor can be changed.

Returns
True if the tensor size can be changed.

Implements ITensorInfo.

Definition at line 285 of file TensorInfo.h.

286  {
287  return _is_resizable;
288  }

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), TensorInfo::set_is_resizable(), and arm_compute::test::validation::TEST_CASE().

◆ num_channels()

size_t num_channels ( ) const
inlineoverridevirtual

The number of channels for each tensor element.

Returns
The number of channels for each tensor element

Implements ITensorInfo.

Definition at line 257 of file TensorInfo.h.

258  {
259  return _num_channels;
260  }

Referenced by ITensor::copy_from(), arm_compute::test::validation::reference::hog_multi_detection(), TensorInfo::init(), TensorInfo::init_auto_padding(), GCAccessor::num_channels(), CLAccessor::num_channels(), TensorInfo::set_num_channels(), and TensorInfo::TensorInfo().

◆ num_dimensions()

size_t num_dimensions ( ) const
inlineoverridevirtual

The number of dimensions of the tensor (rank)

Returns
The number of dimensions of the tensor (rank)

Implements ITensorInfo.

Definition at line 253 of file TensorInfo.h.

254  {
255  return _tensor_shape.num_dimensions();
256  }
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122

References Dimensions< T >::num_dimensions().

Referenced by GCConvolutionLayerReshapeWeights::configure(), GCDirectConvolutionLayerKernel< kernel_size >::configure(), CLLaplacianReconstruct::configure(), GCFullyConnectedLayer::configure(), CLGaussianPyramidHalf::configure(), GCConvolutionLayer::configure(), CLGaussianPyramidOrb::configure(), and ITensor::copy_from().

◆ offset_element_in_bytes()

int32_t offset_element_in_bytes ( const Coordinates pos) const
overridevirtual

The offset in bytes from the beginning of the memory allocation to access the element at position (x, y, z ...)

Parameters
[in]posVector with the coordinates of the element to access. The size of this vector must be equal to the number of dimensions of the tensor
Returns
Offset in bytes from the beginning of the memory allocation to access the element (x, y, z, ...)

Implements ITensorInfo.

Definition at line 394 of file TensorInfo.cpp.

395 {
397 
398  int32_t offset = _offset_first_element_in_bytes;
399 
400  for(size_t i = 0; i < _tensor_shape.num_dimensions(); ++i)
401  {
402  offset += pos[i] * _strides_in_bytes[i];
403  }
404 
405  return offset;
406 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
#define ARM_COMPUTE_ERROR_ON_COORDINATES_DIMENSIONS_GTE(p, md)
Definition: Validate.h:244
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122

References ARM_COMPUTE_ERROR_ON_COORDINATES_DIMENSIONS_GTE, Dimensions< T >::num_dimensions(), and offset().

Referenced by TensorAllocator::init().

◆ offset_first_element_in_bytes()

size_t offset_first_element_in_bytes ( ) const
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

Returns
The offset in bytes to access the first element of the tensor.

Implements ITensorInfo.

Definition at line 244 of file TensorInfo.h.

245  {
246  return _offset_first_element_in_bytes;
247  }

Referenced by TensorAllocator::init(), and TensorInfo::init().

◆ operator=() [1/2]

TensorInfo& operator= ( const TensorInfo )
default

Allow instances of this class to be copied.

◆ operator=() [2/2]

TensorInfo& operator= ( TensorInfo &&  )
default

Allow instances of this class to be moved.

◆ padding()

PaddingSize padding ( ) const
inlineoverridevirtual

Padding of tensor.

Returns
Padding.

Implements ITensorInfo.

Definition at line 277 of file TensorInfo.h.

278  {
279  return _padding;
280  }

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), TensorInfo::extend_padding(), arm_compute::test::validation::if(), GCAccessor::padding(), and CLAccessor::padding().

◆ quantization_info()

◆ reset_padding()

ITensorInfo & reset_padding ( )
overridevirtual

Resets the padding settings of the tensor.

Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 384 of file TensorInfo.cpp.

385 {
386  _padding = PaddingSize();
387  if(((_format != Format::UNKNOWN) || (_data_type != DataType::UNKNOWN)) && _total_size != 0)
388  {
389  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
390  }
391  return *this;
392 }
BorderSize PaddingSize
Container for 2D padding size.
Definition: Types.h:356

References arm_compute::UNKNOWN.

◆ set_data_layout()

ITensorInfo & set_data_layout ( const DataLayout data_layout)
overridevirtual

Set the data layout of the tensor.

Parameters
[in]data_layoutDataLayout containing the layout data information.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 378 of file TensorInfo.cpp.

379 {
380  _data_layout = data_layout;
381  return *this;
382 }
DataLayout data_layout() const override
Get the data layout of the tensor.
Definition: TensorInfo.h:315

References TensorInfo::data_layout().

Referenced by NECropResize::configure(), CLCropResize::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), and NEDeconvolutionLayer::configure().

◆ set_data_type()

ITensorInfo & set_data_type ( DataType  data_type)
overridevirtual

Set the data type to the specified value.

Warning
This resets the format to UNKNOWN.
Parameters
[in]data_typeThe new data type.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 319 of file TensorInfo.cpp.

320 {
321  _data_type = data_type;
322  _format = Format::UNKNOWN;
323  return set_tensor_shape(tensor_shape()); // Force total size and strides to update
324 }
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:265
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
Definition: TensorInfo.cpp:350
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:261

References TensorInfo::data_type(), TensorInfo::set_tensor_shape(), TensorInfo::tensor_shape(), and arm_compute::UNKNOWN.

Referenced by NEL2NormalizeLayer::validate(), NEReductionOperation::validate(), CLL2NormalizeLayer::validate(), CLArgMinMaxLayer::validate(), CLReductionOperation::validate(), NEGenerateProposalsLayer::validate(), CLGenerateProposalsLayer::validate(), and CLGEMMDeconvolutionLayer::validate().

◆ set_format()

ITensorInfo & set_format ( Format  format)
overridevirtual

Set the format of an already initialized tensor.

Note
If the data type has already been configured (i.e. not UNKNOWN) it must match the new format. If data type hasn't been configured it will be based on the format.
Parameters
[in]formatSingle-plane format of the tensor.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 333 of file TensorInfo.cpp.

334 {
335  _format = format;
336 
337  if(_data_type == DataType::UNKNOWN)
338  {
339  _num_channels = num_channels_from_format(format);
340  _data_type = data_type_from_format(format);
341  }
342  else
343  {
346  }
347  return *this;
348 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:482
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:269
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
Definition: Utils.h:219

References ARM_COMPUTE_ERROR_ON, arm_compute::data_type_from_format(), TensorInfo::format(), arm_compute::num_channels_from_format(), and arm_compute::UNKNOWN.

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

◆ set_is_dynamic()

ITensorInfo& set_is_dynamic ( bool  is_dynamic)
inlineoverridevirtual

Set the flag whether the tensor size is dynamic.

Parameters
[in]is_dynamicFlag that marks the tensor if it's dynamic.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 298 of file TensorInfo.h.

299  {
300  _is_dynamic = is_dynamic;
301  return *this;
302  }
bool is_dynamic() const override
Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/func...
Definition: TensorInfo.h:289

References TensorInfo::is_dynamic().

◆ set_is_resizable()

ITensorInfo& set_is_resizable ( bool  is_resizable)
inlineoverridevirtual

Set the flag whether the tensor size can be changed.

Parameters
[in]is_resizableFlag that marks the tensor if it can be changed or not.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 293 of file TensorInfo.h.

294  {
295  _is_resizable = is_resizable;
296  return *this;
297  }
bool is_resizable() const override
Flag indicating whether the size of the tensor can be changed.
Definition: TensorInfo.h:285

References TensorInfo::is_resizable().

Referenced by TensorAllocator::allocate(), GCTensorAllocator::allocate(), CLTensorAllocator::allocate(), TensorAllocator::free(), GCTensorAllocator::free(), CLTensorAllocator::free(), TensorAllocator::import_memory(), CLTensorAllocator::import_memory(), and TensorAllocator::~TensorAllocator().

◆ set_num_channels()

ITensorInfo & set_num_channels ( int  num_channels)
overridevirtual

Set the number of channels to the specified value.

Warning
This resets the format to UNKNOWN.
Parameters
[in]num_channelsNew number of channels.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 326 of file TensorInfo.cpp.

327 {
328  _num_channels = num_channels;
329  _format = Format::UNKNOWN;
330  return *this;
331 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:257

References TensorInfo::num_channels(), and arm_compute::UNKNOWN.

◆ set_quantization_info()

ITensorInfo & set_quantization_info ( const QuantizationInfo quantization_info)
overridevirtual

Set the quantization settings (scale and offset) of the tensor.

Parameters
[in]quantization_infoQuantizationInfo containing the scale and offset
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 372 of file TensorInfo.cpp.

373 {
374  _quantization_info = quantization_info;
375  return *this;
376 }
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:311

References TensorInfo::quantization_info().

Referenced by CLLSTMLayerQuantized::configure(), CLGEMMDeconvolutionLayer::configure(), NEGEMMConvolutionLayer::configure(), CLGEMMConvolutionLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), CLLSTMLayerQuantized::validate(), NELSTMLayerQuantized::validate(), and NEGEMMConvolutionLayer::validate().

◆ set_tensor_shape()

ITensorInfo & set_tensor_shape ( const TensorShape shape)
overridevirtual

Set the shape of an already initialized tensor.

Warning
Changing the shape requires to recompute the strides and is therefore only possible if the tensor hasn't been allocated yet.
Parameters
[in]shapeNew tensor shape.
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 350 of file TensorInfo.cpp.

351 {
352  _tensor_shape = shape;
353  _offset_first_element_in_bytes = 0;
354  _strides_in_bytes = compute_strides(*this);
355 
356  if(_tensor_shape.num_dimensions() == 0)
357  {
358  _total_size = _strides_in_bytes[0];
359  }
360  else
361  {
362  const unsigned int idx_last_dimension = _tensor_shape.num_dimensions() - 1;
363  _total_size = _tensor_shape[idx_last_dimension] * _strides_in_bytes[idx_last_dimension];
364  }
365 
366  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
367 
368  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
369  return *this;
370 }
Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fixed_strides)
Create a strides object based on the provided strides and the tensor dimensions.
Definition: Helpers.h:535
Coordinates of an item.
Definition: Coordinates.h:37
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
Container for valid region of a window.
Definition: Types.h:184

References arm_compute::compute_strides(), Dimensions< T >::num_dimensions(), and arm_compute::test::validation::shape.

Referenced by TensorInfo::init(), and TensorInfo::set_data_type().

◆ set_valid_region()

void set_valid_region ( const ValidRegion valid_region)
inlineoverridevirtual

Set the valid region of the tensor.

Parameters
[in]valid_regionValid region to set.

Implements ITensorInfo.

Definition at line 307 of file TensorInfo.h.

308  {
309  _valid_region = valid_region;
310  }
ValidRegion valid_region() const override
Valid region of the tensor.
Definition: TensorInfo.h:303

References TensorInfo::valid_region().

◆ strides_in_bytes()

const Strides& strides_in_bytes ( ) const
inlineoverridevirtual

The strides in bytes for accessing each dimension of the tensor.

Returns
Strides in bytes for each tensor dimension

Implements ITensorInfo.

Definition at line 240 of file TensorInfo.h.

241  {
242  return _strides_in_bytes;
243  }

Referenced by TensorAllocator::init(), and TensorInfo::init().

◆ tensor_shape()

const TensorShape& tensor_shape ( ) const
inlineoverridevirtual

Size for each dimension of the tensor.

Returns
A vector with the size for each dimension of the tensor

Implements ITensorInfo.

Definition at line 261 of file TensorInfo.h.

262  {
263  return _tensor_shape;
264  }

Referenced by arm_compute::calculate_valid_region_scale(), CLWinogradConvolutionLayer::configure(), CLFFTConvolutionLayer::configure(), NEFFTConvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), GCConvolutionLayer::configure(), CLGEMMConvolutionLayer::configure(), ITensor::copy_from(), arm_compute::graph::backends::detail::create_convolution_layer(), arm_compute::graph::backends::detail::create_convolution_layer< GCConvolutionLayerFunctions, GCTargetInfo >(), arm_compute::graph::backends::detail::create_convolution_layer< NEConvolutionLayerFunctions, NETargetInfo >(), arm_compute::graph::backends::detail::create_deconvolution_layer(), arm_compute::graph::backends::detail::create_depthwise_convolution_layer(), arm_compute::graph::backends::detail::create_depthwise_convolution_layer< GCDepthwiseConvolutionLayerFunctions, GCTargetInfo >(), arm_compute::graph::backends::detail::create_fully_connected_layer(), arm_compute::graph::backends::detail::create_fused_convolution_batch_normalization_layer(), arm_compute::graph::backends::detail::create_fused_depthwise_convolution_batch_normalization_layer(), arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::test::validation::reference::hog_multi_detection(), TensorAllocator::init(), TensorInfo::init(), TensorInfo::init_auto_padding(), GCAccessor::num_elements(), CLAccessor::num_elements(), TensorInfo::set_data_type(), GCAccessor::shape(), CLAccessor::shape(), TensorInfo::TensorInfo(), arm_compute::test::validation::TEST_CASE(), CLWinogradConvolutionLayer::validate(), NEWinogradConvolutionLayer::validate(), CLLSTMLayerQuantized::validate(), and NELSTMLayerQuantized::validate().

◆ total_size()

size_t total_size ( ) const
inlineoverridevirtual

Returns the total size of the tensor in bytes.

Returns
Total size of the tensor in bytes.

Implements ITensorInfo.

Definition at line 273 of file TensorInfo.h.

274  {
275  return _total_size;
276  }

Referenced by CLTensorAllocator::allocate(), TensorAllocator::init(), TensorInfo::init_auto_padding(), CLFastCorners::run(), GCAccessor::size(), CLAccessor::size(), and arm_compute::test::validation::TEST_CASE().

◆ valid_region()

ValidRegion valid_region ( ) const
inlineoverridevirtual

Valid region of the tensor.

All elements in the valid region have defined values, i.e. are not undefined.

Returns
The valid region.

Implements ITensorInfo.

Definition at line 303 of file TensorInfo.h.

304  {
305  return _valid_region;
306  }

Referenced by arm_compute::calculate_valid_region_scale(), ITensor::copy_from(), arm_compute::test::validation::DATA_TEST_CASE(), and TensorInfo::set_valid_region().


The documentation for this class was generated from the following files: