Compute Library
 23.11
Accessor Class Reference

Accessor implementation for Tensor objects. More...

#include <Accessor.h>

Collaboration diagram for Accessor:
[legend]

Public Member Functions

 Accessor (ITensor &tensor)
 Create an accessor for the given tensor. More...
 
 Accessor (const Accessor &)=delete
 Prevent instances of this class from being copy constructed. More...
 
Accessoroperator= (const Accessor &)=delete
 Prevent instances of this class from being copied. More...
 
 Accessor (Accessor &&)=default
 Allow instances of this class to be move constructed. More...
 
const void * data () const
 Get the tensor data. More...
 
void * data ()
 Get the tensor data. More...
 
TensorShape shape () const override
 Shape of the tensor. More...
 
size_t element_size () const override
 Size of each element in the tensor in bytes. More...
 
size_t size () const override
 Total size of the tensor in bytes. More...
 
Format format () const override
 Image format of the tensor. More...
 
DataLayout data_layout () const override
 Data layout of the tensor. More...
 
DataType data_type () const override
 Data type of the tensor. More...
 
int num_channels () const override
 Number of channels of the tensor. More...
 
int num_elements () const override
 Number of elements of the tensor. More...
 
PaddingSize padding () const override
 Available padding around the tensor. More...
 
QuantizationInfo quantization_info () const override
 Quantization info in case of asymmetric quantized type. More...
 
const void * operator() (const Coordinates &coord) const override
 Read only access to the specified element. More...
 
void * operator() (const Coordinates &coord) override
 Access to the specified element. More...
 
- Public Member Functions inherited from IAccessor
virtual ~IAccessor ()=default
 Virtual destructor. More...
 

Detailed Description

Accessor implementation for Tensor objects.

Definition at line 35 of file Accessor.h.

Constructor & Destructor Documentation

◆ Accessor() [1/3]

Accessor ( ITensor tensor)
inline

Create an accessor for the given tensor.

Parameters
[in,out]tensorTo be accessed tensor.

Definition at line 79 of file Accessor.h.

80  : _tensor{ tensor }
81 {
82 }

References tensor.

◆ Accessor() [2/3]

Accessor ( const Accessor )
delete

Prevent instances of this class from being copy constructed.

◆ Accessor() [3/3]

Accessor ( Accessor &&  )
default

Allow instances of this class to be move constructed.

Member Function Documentation

◆ data() [1/2]

void* data ( )

Get the tensor data.

Returns
a pointer to the tensor data.

◆ data() [2/2]

void * data ( ) const
inline

Get the tensor data.

Returns
a constant pointer to the tensor data.

Definition at line 134 of file Accessor.h.

135 {
136  return _tensor.buffer();
137 }

References ITensor::buffer().

◆ data_layout()

DataLayout data_layout ( ) const
inlineoverridevirtual

Data layout of the tensor.

Returns
the data layout of the tensor.

Implements IAccessor.

Definition at line 104 of file Accessor.h.

105 {
106  return _tensor.info()->data_layout();
107 }

References ITensorInfo::data_layout(), and ITensor::info().

◆ data_type()

DataType data_type ( ) const
inlineoverridevirtual

Data type of the tensor.

Returns
the data type of the tensor.

Implements IAccessor.

Definition at line 109 of file Accessor.h.

110 {
111  return _tensor.info()->data_type();
112 }

References ITensorInfo::data_type(), and ITensor::info().

◆ element_size()

size_t element_size ( ) const
inlineoverridevirtual

Size of each element in the tensor in bytes.

Returns
the size of each element in the tensor in bytes.

Implements IAccessor.

Definition at line 89 of file Accessor.h.

90 {
91  return _tensor.info()->element_size();
92 }

References ITensorInfo::element_size(), and ITensor::info().

◆ format()

Format format ( ) const
inlineoverridevirtual

Image format of the tensor.

Returns
the format of the tensor.

Implements IAccessor.

Definition at line 99 of file Accessor.h.

100 {
101  return _tensor.info()->format();
102 }

References ITensorInfo::format(), and ITensor::info().

◆ num_channels()

int num_channels ( ) const
inlineoverridevirtual

Number of channels of the tensor.

Returns
the number of channels of the tensor.

Implements IAccessor.

Definition at line 114 of file Accessor.h.

115 {
116  return _tensor.info()->num_channels();
117 }

References ITensor::info(), and ITensorInfo::num_channels().

◆ num_elements()

int num_elements ( ) const
inlineoverridevirtual

Number of elements of the tensor.

Returns
the number of elements of the tensor.

Implements IAccessor.

Definition at line 119 of file Accessor.h.

120 {
121  return _tensor.info()->tensor_shape().total_size();
122 }

References ITensor::info(), ITensorInfo::tensor_shape(), and TensorShape::total_size().

◆ operator()() [1/2]

const void * operator() ( const Coordinates coord) const
inlineoverridevirtual

Read only access to the specified element.

Parameters
[in]coordCoordinates of the desired element.
Returns
A pointer to the desired element.

Implements IAccessor.

Definition at line 144 of file Accessor.h.

145 {
146  return _tensor.ptr_to_element(coord);
147 }

References ITensor::ptr_to_element().

◆ operator()() [2/2]

void * operator() ( const Coordinates coord)
inlineoverridevirtual

Access to the specified element.

Parameters
[in]coordCoordinates of the desired element.
Returns
A pointer to the desired element.

Implements IAccessor.

Definition at line 149 of file Accessor.h.

150 {
151  return _tensor.ptr_to_element(coord);
152 }

References ITensor::ptr_to_element().

◆ operator=()

Accessor& operator= ( const Accessor )
delete

Prevent instances of this class from being copied.

◆ padding()

PaddingSize padding ( ) const
inlineoverridevirtual

Available padding around the tensor.

Returns
the available padding around the tensor.

Implements IAccessor.

Definition at line 124 of file Accessor.h.

125 {
126  return _tensor.info()->padding();
127 }

References ITensor::info(), and ITensorInfo::padding().

◆ quantization_info()

QuantizationInfo quantization_info ( ) const
inlineoverridevirtual

Quantization info in case of asymmetric quantized type.

Returns

Implements IAccessor.

Definition at line 129 of file Accessor.h.

130 {
131  return _tensor.info()->quantization_info();
132 }

References ITensor::info(), and ITensorInfo::quantization_info().

◆ shape()

TensorShape shape ( ) const
inlineoverridevirtual

Shape of the tensor.

Returns
the shape of the tensor.

Implements IAccessor.

Definition at line 84 of file Accessor.h.

85 {
86  return _tensor.info()->tensor_shape();
87 }

References ITensor::info(), and ITensorInfo::tensor_shape().

◆ size()

size_t size ( ) const
inlineoverridevirtual

Total size of the tensor in bytes.

Returns
the total size of the tensor in bytes.

Implements IAccessor.

Definition at line 94 of file Accessor.h.

95 {
96  return _tensor.info()->total_size();
97 }

References ITensor::info(), and ITensorInfo::total_size().


The documentation for this class was generated from the following file:
arm_compute::ITensorInfo::data_layout
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
arm_compute::ITensorInfo::num_channels
virtual size_t num_channels() const =0
The number of channels for each tensor element.
arm_compute::ITensorInfo::tensor_shape
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
arm_compute::ITensorInfo::element_size
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
arm_compute::ITensor::info
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
arm_compute::TensorShape::total_size
size_t total_size() const
Collapses all dimensions to a single linear total size.
Definition: TensorShape.h:175
arm_compute::ITensorInfo::data_type
virtual DataType data_type() const =0
Data type used for each element of the tensor.
tensor
CLTensor * tensor
Pointer to the auxiliary tensor.
Definition: ClWorkloadRuntime.cpp:67
arm_compute::ITensorInfo::quantization_info
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
arm_compute::ITensor::ptr_to_element
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
Definition: ITensor.h:63
arm_compute::ITensorInfo::format
virtual Format format() const =0
Colour format of the image.
arm_compute::ITensorInfo::total_size
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
arm_compute::ITensor::buffer
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory.
arm_compute::ITensorInfo::padding
virtual PaddingSize padding() const =0
Padding of tensor.