Compute Library
 21.11
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...
 
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...
 
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...
 
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_tensor_dims_state (const TensorDimsState &state) override
 Set the state for each dimension of the 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...
 
const TensorDimsStatetensor_dims_state () const override
 State of each dimension of the tensor shape. More...
 
DataType data_type () const override
 Data type used for each element of the tensor. More...
 
Format format () const override
 Colour format of the image. More...
 
size_t total_size () const override
 Returns the total size of the tensor in bytes. More...
 
PaddingSize padding () const override
 Padding of tensor. More...
 
bool has_padding () const override
 Checks if the tensor has been allocated with padding or not. More...
 
bool is_resizable () const override
 Flag indicating whether the size of the tensor can be changed. More...
 
bool is_dynamic () const override
 Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/function execution. More...
 
bool are_values_constant () const override
 Flag indicating whether the values of the tensor are constant, meaning that they 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...
 
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...
 
ITensorInfoset_are_values_constant (bool are_values_constant) override
 Set the flag whether the tensor values can change during kernel/function execution. 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

- Public Types inherited from ITensorInfo
using TensorDimsState = std::vector< int >
 
- Static Public Member Functions inherited from ITensorInfo
static constexpr int32_t get_dynamic_state_value ()
 Get the value representing dynamic dimension state. More...
 
static constexpr int32_t get_static_state_value ()
 Get the value representing static dimension state. More...
 
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 43 of file TensorInfo.h.

Constructor & Destructor Documentation

◆ TensorInfo() [1/11]

Default constructor.

Definition at line 36 of file TensorInfo.cpp.

References arm_compute::NCHW.

37  : _total_size(0), _offset_first_element_in_bytes(0), _strides_in_bytes(), _num_channels(0), _tensor_shape(), _dims_state(), _data_type(DataType::UNKNOWN), _format(Format::UNKNOWN), _is_resizable{ true },
38  _valid_region{ Coordinates(), _tensor_shape }, _padding{ 0 }, _quantization_info(), _data_layout(DataLayout::NCHW), _are_values_constant(true)
39 {
40 }
Num samples, channels, height, width.

◆ ~TensorInfo()

~TensorInfo ( )
default

Default destructor.

◆ TensorInfo() [2/11]

TensorInfo ( const ITensorInfo info)

Allow instances of this class to be copy constructed.

Definition at line 42 of file TensorInfo.cpp.

References ITensorInfo::are_values_constant(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::format(), ITensorInfo::is_resizable(), ITensorInfo::num_channels(), ITensorInfo::offset_first_element_in_bytes(), ITensorInfo::padding(), ITensorInfo::quantization_info(), ITensorInfo::strides_in_bytes(), ITensorInfo::tensor_dims_state(), ITensorInfo::tensor_shape(), ITensorInfo::total_size(), and ITensorInfo::valid_region().

43  : TensorInfo()
44 {
45  _total_size = info.total_size();
46  _offset_first_element_in_bytes = info.offset_first_element_in_bytes();
47  _strides_in_bytes = info.strides_in_bytes();
48  _num_channels = info.num_channels();
49  _tensor_shape = info.tensor_shape();
50  _dims_state = info.tensor_dims_state();
51  _data_type = info.data_type();
52  _format = info.format();
53  _is_resizable = info.is_resizable();
54  _valid_region = info.valid_region();
55  _padding = info.padding();
56  _quantization_info = info.quantization_info();
57  _data_layout = info.data_layout();
58  _are_values_constant = info.are_values_constant();
59 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36
DataLayout data_layout
Data layout to use.

◆ TensorInfo() [3/11]

TensorInfo ( const TensorInfo )
default

Allow instances of this class to be copy constructed.

◆ TensorInfo() [4/11]

TensorInfo ( TensorInfo &&  )
default

Allow instances of this class to be move constructed.

◆ TensorInfo() [5/11]

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 61 of file TensorInfo.cpp.

62  : TensorInfo(TensorShape(), format)
63 {
64 }
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36

◆ TensorInfo() [6/11]

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 66 of file TensorInfo.cpp.

67  : TensorInfo(TensorShape(width, height), format)
68 {
69 }
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36

◆ TensorInfo() [7/11]

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 71 of file TensorInfo.cpp.

References TensorInfo::init().

72  : TensorInfo()
73 {
75 }
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ TensorInfo() [8/11]

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 77 of file TensorInfo.cpp.

References TensorInfo::init().

78  : TensorInfo()
79 {
80  init(TensorShape(), num_channels, data_type);
81 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36

◆ TensorInfo() [9/11]

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 83 of file TensorInfo.cpp.

References TensorInfo::init().

84  : TensorInfo()
85 {
87 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ TensorInfo() [10/11]

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 96 of file TensorInfo.cpp.

References TensorInfo::data_layout(), and TensorInfo::init().

97  : TensorInfo()
98 {
100  _data_layout = data_layout;
101 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
DataLayout data_layout() const override
Get the data layout of the tensor.
Definition: TensorInfo.h:291
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ TensorInfo() [11/11]

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 89 of file TensorInfo.cpp.

References TensorInfo::init().

90  : TensorInfo()
91 {
93  _quantization_info = std::move(quantization_info);
94 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:287
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103
TensorInfo()
Default constructor.
Definition: TensorInfo.cpp:36
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

Member Function Documentation

◆ are_values_constant()

bool are_values_constant ( ) const
inlineoverridevirtual

Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel/function execution.

Returns
True if values are constant else false

Implements ITensorInfo.

Definition at line 270 of file TensorInfo.h.

Referenced by TensorInfo::set_are_values_constant().

271  {
272  return _are_values_constant;
273  }

◆ 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 190 of file TensorInfo.cpp.

References ARM_COMPUTE_ERROR_ON, BorderSize::bottom, arm_compute::compute_strides(), TensorInfo::element_size(), TensorInfo::extend_padding(), BorderSize::left, Dimensions< T >::num_dimensions(), TensorInfo::padding(), BorderSize::right, BorderSize::top, and TensorShape::total_size().

Referenced by TensorInfo::init_auto_padding().

191 {
192  ARM_COMPUTE_ERROR_ON(!_is_resizable);
193 
194  // Some kernels compute 32 elements at the time, worst case scenario they
195  // will read 32 values after the last element
196  const size_t extra_pad_x = _tensor_shape.num_dimensions() < 1 ? 0 : 32;
197  const size_t pad_x = _tensor_shape.num_dimensions() < 1 ? 0 : 4;
198  const size_t pad_y = _tensor_shape.num_dimensions() < 2 ? 0 : 4;
199 
200  return extend_padding(PaddingSize(pad_y, pad_x + extra_pad_x, pad_y, pad_x));
201 }
bool extend_padding(const PaddingSize &padding) override
Update the offset to the first element, the strides and the total size.
Definition: TensorInfo.cpp:247
#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:384
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:143

◆ clone()

◆ 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 291 of file TensorInfo.h.

Referenced by CLAccessor::data_layout(), TensorInfo::set_data_layout(), and TensorInfo::TensorInfo().

292  {
293  return _data_layout;
294  }

◆ data_type()

◆ dimension() [1/2]

size_t dimension ( size_t  index) const
inlineoverridevirtual

Return the size of the requested dimension.

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

Implements ITensorInfo.

Definition at line 205 of file TensorInfo.h.

Referenced by CpuGemmLowpMatrixMultiplyCore::configure().

206  {
207  return _tensor_shape[index];
208  }

◆ 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 209 of file TensorInfo.h.

References arm_compute::get_data_layout_dimension_index().

210  {
211  return get_data_layout_dimension_index(_data_layout, dimension);
212  }
size_t dimension(size_t index) const override
Return the size of the requested dimension.
Definition: TensorInfo.h:205
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:193

◆ 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 222 of file TensorInfo.h.

References arm_compute::data_size_from_type().

Referenced by TensorInfo::auto_padding(), CLAccessor::element_size(), and CLQLSTMLayer::prepare().

223  {
224  return data_size_from_type(_data_type) * _num_channels;
225  }
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
Definition: Utils.h:106

◆ 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 247 of file TensorInfo.cpp.

References ARM_COMPUTE_ERROR_ON, BorderSize::bottom, BorderSize::left, BorderSize::right, and BorderSize::top.

Referenced by TensorInfo::auto_padding(), arm_compute::test::validation::DATA_TEST_CASE(), and CpuGemmConv2d::run().

248 {
249  ARM_COMPUTE_ERROR_ON(!_is_resizable);
250 
251  bool updated = false;
252 
253  if(padding.top > _padding.top)
254  {
255  _padding.top = padding.top;
256  updated = true;
257  }
258 
259  if(padding.right > _padding.right)
260  {
261  _padding.right = padding.right;
262  updated = true;
263  }
264 
265  if(padding.bottom > _padding.bottom)
266  {
267  _padding.bottom = padding.bottom;
268  updated = true;
269  }
270 
271  if(padding.left > _padding.left)
272  {
273  _padding.left = padding.left;
274  updated = true;
275  }
276 
277  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
278 
279  return updated;
280 }
unsigned int top
top of the border
Definition: Types.h:377
#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:379
PaddingSize padding() const override
Padding of tensor.
Definition: TensorInfo.h:254
unsigned int left
left of the border
Definition: Types.h:380
unsigned int right
right of the border
Definition: Types.h:378

◆ format()

Format format ( ) const
inlineoverridevirtual

Colour format of the image.

Returns
Colour format of the image

Implements ITensorInfo.

Definition at line 246 of file TensorInfo.h.

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

247  {
248  return _format;
249  }

◆ 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 258 of file TensorInfo.h.

References BorderSize::empty().

259  {
260  return !_padding.empty();
261  }
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:302

◆ init() [1/6]

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 103 of file TensorInfo.cpp.

Referenced by CpuWinogradConv2d::configure(), arm_compute::detail::convert_to_legacy_tensor_info(), arm_compute::test::validation::DATA_TEST_CASE(), TensorAllocator::init(), TensorInfo::init(), and TensorInfo::TensorInfo().

104 {
105  init(TensorShape(), format);
106 }
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103

◆ init() [2/6]

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 108 of file TensorInfo.cpp.

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

109 {
112 
113  init(tensor_shape, num_channels, type);
114 
115  _format = format;
116 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:486
decltype(strategy::transforms) typedef type
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
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:103
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234
DataType
Available data types.
Definition: Types.h:79

◆ init() [3/6]

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 118 of file TensorInfo.cpp.

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

121 {
124 
125  init(tensor_shape, num_channels, type, strides_in_bytes, offset_first_element_in_bytes, total_size_in_bytes);
126 
127  _format = format;
128 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:486
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
Definition: TensorInfo.h:213
decltype(strategy::transforms) typedef type
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
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:103
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:217
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234
DataType
Available data types.
Definition: Types.h:79

◆ init() [4/6]

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 130 of file TensorInfo.cpp.

References TensorInfo::init().

131 {
132  init(TensorShape(), num_channels, data_type);
133 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
void init(Format format)
Initialize the tensor info with just a format.
Definition: TensorInfo.cpp:103

◆ init() [5/6]

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 135 of file TensorInfo.cpp.

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

136 {
138 
139  _data_type = data_type;
140  _num_channels = num_channels;
141  _format = Format::UNKNOWN;
142 
144 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
#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:242
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
Definition: TensorInfo.cpp:318
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ init() [6/6]

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 146 of file TensorInfo.cpp.

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.

149 {
151 
152  _data_type = data_type;
153  _num_channels = num_channels;
154  _format = Format::UNKNOWN;
155  _tensor_shape = tensor_shape;
156  _offset_first_element_in_bytes = offset_first_element_in_bytes;
157  _strides_in_bytes = strides_in_bytes;
158  _total_size = total_size_in_bytes;
159 
160  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
161 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
#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:213
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
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:217
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ init_auto_padding() [1/2]

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 163 of file TensorInfo.cpp.

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

164 {
167  size_t total_size = init_auto_padding(tensor_shape, num_channels, type);
168 
169  _format = format;
170 
171  return total_size;
172 }
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)
Definition: TensorInfo.cpp:163
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
size_t num_channels_from_format(Format format)
Return the number of channels for a given single-planar pixel format.
Definition: Utils.h:486
decltype(strategy::transforms) typedef type
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
size_t total_size() const override
Returns the total size of the tensor in bytes.
Definition: TensorInfo.h:250
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:234
DataType
Available data types.
Definition: Types.h:79

◆ init_auto_padding() [2/2]

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 174 of file TensorInfo.cpp.

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

175 {
177 
178  _data_type = data_type;
179  _num_channels = num_channels;
180  _format = Format::UNKNOWN;
181  _tensor_shape = tensor_shape;
182 
183  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
184 
185  auto_padding();
186 
187  return _total_size;
188 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230
#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:190
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ 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 266 of file TensorInfo.h.

References ITensorInfo::get_dynamic_state_value().

267  {
268  return std::find(std::cbegin(_dims_state), std::cend(_dims_state), get_dynamic_state_value()) != std::cend(_dims_state);
269  }
static constexpr int32_t get_dynamic_state_value()
Get the value representing dynamic dimension state.
Definition: ITensorInfo.h:49

◆ 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 262 of file TensorInfo.h.

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

263  {
264  return _is_resizable;
265  }

◆ 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 230 of file TensorInfo.h.

Referenced by TensorInfo::init(), TensorInfo::init_auto_padding(), CLAccessor::num_channels(), TensorInfo::set_num_channels(), and arm_compute::test::validation::TEST_CASE().

231  {
232  return _num_channels;
233  }

◆ 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 226 of file TensorInfo.h.

References Dimensions< T >::num_dimensions().

Referenced by arm_compute::detail::convert_to_descriptor().

227  {
228  return _tensor_shape.num_dimensions();
229  }
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:143

◆ 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 368 of file TensorInfo.cpp.

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

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

369 {
371 
372  int32_t offset = _offset_first_element_in_bytes;
373 
374  for(size_t i = 0; i < _tensor_shape.num_dimensions(); ++i)
375  {
376  offset += pos[i] * _strides_in_bytes[i];
377  }
378 
379  return offset;
380 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:1069
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:143
#define ARM_COMPUTE_ERROR_ON_COORDINATES_DIMENSIONS_GTE(p, md)
Definition: Validate.h:240

◆ 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 217 of file TensorInfo.h.

References TensorInfo::offset_element_in_bytes().

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

218  {
219  return _offset_first_element_in_bytes;
220  }

◆ 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 254 of file TensorInfo.h.

Referenced by TensorInfo::auto_padding(), arm_compute::test::validation::DATA_TEST_CASE(), CLAccessor::padding(), and arm_compute::test::validation::TEST_CASE().

255  {
256  return _padding;
257  }

◆ quantization_info()

QuantizationInfo quantization_info ( ) const
inlineoverridevirtual

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

Returns
A QuantizationInfo containing the scale and offset.

Implements ITensorInfo.

Definition at line 287 of file TensorInfo.h.

Referenced by CpuGemmLowpMatrixMultiplyCore::configure(), CLQLSTMLayer::configure(), CLAccessor::quantization_info(), TensorInfo::set_quantization_info(), and arm_compute::test::validation::TEST_CASE().

288  {
289  return _quantization_info;
290  }

◆ reset_padding()

ITensorInfo & reset_padding ( )
overridevirtual

Resets the padding settings of the tensor.

Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 358 of file TensorInfo.cpp.

References arm_compute::UNKNOWN.

359 {
360  _padding = PaddingSize();
361  if(((_format != Format::UNKNOWN) || (_data_type != DataType::UNKNOWN)) && _total_size != 0)
362  {
363  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
364  }
365  return *this;
366 }
BorderSize PaddingSize
Container for 2D padding size.
Definition: Types.h:384

◆ set_are_values_constant()

ITensorInfo& set_are_values_constant ( bool  are_values_constant)
inlineoverridevirtual

Set the flag whether the tensor values can change during kernel/function execution.

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

Implements ITensorInfo.

Definition at line 295 of file TensorInfo.h.

References TensorInfo::are_values_constant().

296  {
297  _are_values_constant = are_values_constant;
298  return *this;
299  }
bool are_values_constant() const override
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
Definition: TensorInfo.h:270

◆ 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 352 of file TensorInfo.cpp.

References TensorInfo::data_layout().

Referenced by CLDepthwiseConvolutionLayer::configure(), NEDeconvolutionLayer::configure(), CLFFTConvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), NEDeviceBackend::create_tensor(), CLDeviceBackend::create_tensor(), arm_compute::test::create_tensor(), arm_compute::test::validation::DATA_TEST_CASE(), and NumPyAccessor::NumPyAccessor().

353 {
354  _data_layout = data_layout;
355  return *this;
356 }
DataLayout data_layout() const override
Get the data layout of the tensor.
Definition: TensorInfo.h:291

◆ 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 287 of file TensorInfo.cpp.

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

Referenced by NEReduceMean::configure(), CLReduceMean::configure(), CpuLogits1DSoftmaxKernel< IS_LOG >::configure(), ClGemmLowpMatrixMultiplyCore::configure(), CpuGemmConv2d::configure(), arm_compute::test::validation::TEST_CASE(), NEL2NormalizeLayer::validate(), NEReductionOperation::validate(), CLL2NormalizeLayer::validate(), CLArgMinMaxLayer::validate(), CLReductionOperation::validate(), NEGenerateProposalsLayer::validate(), CLGenerateProposalsLayer::validate(), and CLGEMMDeconvolutionLayer::validate().

288 {
289  _data_type = data_type;
290  _format = Format::UNKNOWN;
291  return set_tensor_shape(tensor_shape()); // Force total size and strides to update
292 }
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:242
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
Definition: TensorInfo.cpp:318
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:234

◆ 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 301 of file TensorInfo.cpp.

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

302 {
303  _format = format;
304 
305  if(_data_type == DataType::UNKNOWN)
306  {
307  _num_channels = num_channels_from_format(format);
308  _data_type = data_type_from_format(format);
309  }
310  else
311  {
314  }
315  return *this;
316 }
#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:486
Format format() const override
Colour format of the image.
Definition: TensorInfo.h:246
DataType data_type_from_format(Format format)
Return the data type used by a given single-planar pixel format.
Definition: Utils.h:219

◆ 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 274 of file TensorInfo.h.

References TensorInfo::is_resizable().

Referenced by TensorAllocator::allocate(), CLTensorAllocator::allocate(), CpuContext::create_activation(), ClContext::create_activation(), TensorAllocator::free(), CLTensorAllocator::free(), TensorAllocator::import_memory(), CLTensorAllocator::import_memory(), and TensorAllocator::~TensorAllocator().

275  {
276  _is_resizable = is_resizable;
277  return *this;
278  }
bool is_resizable() const override
Flag indicating whether the size of the tensor can be changed.
Definition: TensorInfo.h:262

◆ 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 294 of file TensorInfo.cpp.

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

295 {
296  _num_channels = num_channels;
297  _format = Format::UNKNOWN;
298  return *this;
299 }
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:230

◆ 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 346 of file TensorInfo.cpp.

References TensorInfo::quantization_info().

Referenced by CpuLogits1DSoftmaxKernel< IS_LOG >::configure(), CLDepthwiseConvolutionLayer::configure(), ClGemmConv2d::configure(), CpuGemmConv2d::configure(), CLGEMMDeconvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), arm_compute::test::create_tensor(), CpuGemmConv2d::validate(), NELSTMLayerQuantized::validate(), and CLLSTMLayerQuantized::validate().

347 {
348  _quantization_info = quantization_info;
349  return *this;
350 }
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:287

◆ set_tensor_dims_state()

ITensorInfo & set_tensor_dims_state ( const TensorDimsState state)
overridevirtual

Set the state for each dimension of the tensor.

This sets the state of each dimension of the shape in terms of dynamic behavior using -1 where appropriate. The index in the state is a 1 to 1 mapping with the shape dimension index. For example if you want to express [?, 3, 3] as a dynamic input then [-1, 3, 3] has to be set as a state

Parameters
[in]stateTensor dimensions state
Returns
Reference to this ITensorInfo object

Implements ITensorInfo.

Definition at line 340 of file TensorInfo.cpp.

341 {
342  _dims_state = state;
343  return *this;
344 }

◆ 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 318 of file TensorInfo.cpp.

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

Referenced by NEQLSTMLayer::configure(), CLQLSTMLayer::configure(), TensorInfo::init(), TensorInfo::set_data_type(), arm_compute::test::validation::TEST_CASE(), NEQLSTMLayer::validate(), and CLQLSTMLayer::validate().

319 {
320  _tensor_shape = shape;
321  _offset_first_element_in_bytes = 0;
322  _strides_in_bytes = compute_strides(*this);
323 
324  if(_tensor_shape.num_dimensions() == 0)
325  {
326  _total_size = _strides_in_bytes[0];
327  }
328  else
329  {
330  const unsigned int idx_last_dimension = _tensor_shape.num_dimensions() - 1;
331  _total_size = static_cast<size_t>(_tensor_shape[idx_last_dimension]) * _strides_in_bytes[idx_last_dimension];
332  }
333 
334  std::tie(_strides_in_bytes, _offset_first_element_in_bytes, _total_size) = calculate_padding_requirements(_padding);
335 
336  _valid_region = ValidRegion{ Coordinates(), _tensor_shape };
337  return *this;
338 }
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: Utils.h:41
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:143

◆ 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 283 of file TensorInfo.h.

References TensorInfo::valid_region().

284  {
285  _valid_region = valid_region;
286  }
ValidRegion valid_region() const override
Valid region of the tensor.
Definition: TensorInfo.h:279

◆ 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 213 of file TensorInfo.h.

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

214  {
215  return _strides_in_bytes;
216  }

◆ tensor_dims_state()

const TensorDimsState& tensor_dims_state ( ) const
inlineoverridevirtual

State of each dimension of the tensor shape.

Returns
A vector with the state for each dimension of the tensor, where -1 specifies dynamic dimension

Implements ITensorInfo.

Definition at line 238 of file TensorInfo.h.

239  {
240  return _dims_state;
241  }

◆ tensor_shape()

◆ total_size()

◆ 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 279 of file TensorInfo.h.

Referenced by TensorInfo::set_valid_region().

280  {
281  return _valid_region;
282  }

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