Compute Library
 22.11
TensorAccessor< T > Class Template Reference

Tensor accessors to make it easier to interface with arm_gemm. More...

#include <WindowIterator.h>

Public Member Functions

 TensorAccessor (const ITensor &tensor)
 Constructor: More...
 
size_t stride (size_t dim) const
 Get the stride of the dimension dim expressed in number of Ts. More...
 
void set_stride (size_t dim, size_t size)
 Manually set the stride of a dimension. More...
 
void set_strides (const Strides &strides)
 Manually set the strides. More...
 
T * get_ptr (unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int w=0)
 Returns a pointer to the element at coordinates (x,y,z,w) More...
 
T * operator() (unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int w=0)
 Returns a pointer to the element at coordinates (x,y,z,w) More...
 
T * first_element ()
 Returns a pointer to the first element of the tensor. More...
 
T * operator() ()
 Returns a pointer to the first element of the tensor. More...
 

Detailed Description

template<typename T>
class arm_compute::TensorAccessor< T >

Tensor accessors to make it easier to interface with arm_gemm.

Definition at line 53 of file WindowIterator.h.

Constructor & Destructor Documentation

◆ TensorAccessor()

TensorAccessor ( const ITensor tensor)
inline

Constructor:

Parameters
[in]tensorSource tensor, must be allocated.

Definition at line 60 of file WindowIterator.h.

61  : _first(tensor.ptr_to_element(Coordinates())), _strides(tensor.info()->strides_in_bytes())
62  {
63  }
CLTensor * tensor
Pointer to the auxiliary tensor.

Member Function Documentation

◆ first_element()

T* first_element ( )
inline

Returns a pointer to the first element of the tensor.

Returns
Pointer to the first element.

Definition at line 123 of file WindowIterator.h.

Referenced by TensorAccessor< T >::operator()().

124  {
125  return reinterpret_cast<T *>(_first);
126  }

◆ get_ptr()

T* get_ptr ( unsigned int  x,
unsigned int  y = 0,
unsigned int  z = 0,
unsigned int  w = 0 
)
inline

Returns a pointer to the element at coordinates (x,y,z,w)

Parameters
[in]xX coordinates
[in]y(optional) Y coordinates
[in]z(optional) Z coordinates
[in]w(optional) W coordinates

Definition at line 102 of file WindowIterator.h.

References arm_compute::test::validation::w.

Referenced by TensorAccessor< T >::operator()().

103  {
104  return reinterpret_cast<T *>(_first + x * _strides[0] + y * _strides[1] + z * _strides[2] + w * _strides[3]);
105  }
SimpleTensor< float > w
Definition: DFT.cpp:156

◆ operator()() [1/2]

T* operator() ( unsigned int  x,
unsigned int  y = 0,
unsigned int  z = 0,
unsigned int  w = 0 
)
inline

Returns a pointer to the element at coordinates (x,y,z,w)

Parameters
[in]xX coordinates
[in]y(optional) Y coordinates
[in]z(optional) Z coordinates
[in]w(optional) W coordinates

Definition at line 114 of file WindowIterator.h.

References TensorAccessor< T >::get_ptr(), and arm_compute::test::validation::w.

115  {
116  return get_ptr(x, y, z, w);
117  }
SimpleTensor< float > w
Definition: DFT.cpp:156
T * get_ptr(unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int w=0)
Returns a pointer to the element at coordinates (x,y,z,w)

◆ operator()() [2/2]

T* operator() ( )
inline

Returns a pointer to the first element of the tensor.

Returns
Pointer to the first element.

Definition at line 132 of file WindowIterator.h.

References TensorAccessor< T >::first_element().

133  {
134  return first_element();
135  }
T * first_element()
Returns a pointer to the first element of the tensor.

◆ set_stride()

void set_stride ( size_t  dim,
size_t  size 
)
inline

Manually set the stride of a dimension.

Parameters
[in]dimDimension of the stride to set.
[in]sizeValue to set the stride to (in bytes).

Definition at line 81 of file WindowIterator.h.

82  {
83  _strides[dim] = size;
84  }

◆ set_strides()

void set_strides ( const Strides strides)
inline

Manually set the strides.

Parameters
[in]stridesStrides to set

Definition at line 90 of file WindowIterator.h.

91  {
92  _strides = strides;
93  }

◆ stride()

size_t stride ( size_t  dim) const
inline

Get the stride of the dimension dim expressed in number of Ts.

Parameters
[in]dimDimension of the wanted stride.
Returns
Stride in number of Ts.

Definition at line 70 of file WindowIterator.h.

References ARM_COMPUTE_ERROR_ON.

71  {
72  ARM_COMPUTE_ERROR_ON(_strides[dim] % sizeof(T) != 0);
73  return _strides[dim] / sizeof(T);
74  }
#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

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