Compute Library
 21.11
ITensorAllocator Class Referenceabstract

Interface to allocate tensors. More...

#include <ITensorAllocator.h>

Public Member Functions

 ITensorAllocator ()=default
 Default constructor. More...
 
 ITensorAllocator (const ITensorAllocator &)=default
 Allow instances of this class to be copy constructed. More...
 
ITensorAllocatoroperator= (const ITensorAllocator &)=default
 Allow instances of this class to be copied. More...
 
 ITensorAllocator (ITensorAllocator &&)=default
 Allow instances of this class to be move constructed. More...
 
ITensorAllocatoroperator= (ITensorAllocator &&)=default
 Allow instances of this class to be moved. More...
 
virtual ~ITensorAllocator ()=default
 Default virtual destructor. More...
 
void init (const TensorInfo &input, size_t alignment=0)
 Initialize a tensor based on the passed TensorInfo. More...
 
void soft_init (TensorInfo &input, size_t alignment=0)
 Initialize a tensor based with a reference TensorInfo. More...
 
TensorInfoinfo ()
 Return a reference to the tensor's metadata. More...
 
const TensorInfoinfo () const
 Return a constant reference to the tensor's metadata. More...
 
size_t alignment () const
 Return underlying's tensor buffer alignment. More...
 
virtual void allocate ()=0
 Interface to be implemented by the child class to allocate the tensor. More...
 
virtual void free ()=0
 Interface to be implemented by the child class to free the allocated tensor. More...
 

Detailed Description

Interface to allocate tensors.

Definition at line 35 of file ITensorAllocator.h.

Constructor & Destructor Documentation

◆ ITensorAllocator() [1/3]

ITensorAllocator ( )
default

Default constructor.

◆ ITensorAllocator() [2/3]

ITensorAllocator ( const ITensorAllocator )
default

Allow instances of this class to be copy constructed.

◆ ITensorAllocator() [3/3]

Allow instances of this class to be move constructed.

◆ ~ITensorAllocator()

virtual ~ITensorAllocator ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ alignment()

size_t alignment ( ) const

Return underlying's tensor buffer alignment.

Returns
Tensor buffer alignment

Definition at line 56 of file ITensorAllocator.cpp.

Referenced by TensorAllocator::allocate(), CLTensorAllocator::allocate(), TensorAllocator::import_memory(), ITensorAllocator::init(), ITensorAllocator::soft_init(), and arm_compute::test::validation::TEST_CASE().

57 {
58  return _alignment;
59 }

◆ allocate()

virtual void allocate ( )
pure virtual

Interface to be implemented by the child class to allocate the tensor.

Note
The child is expected to use the TensorInfo to get the size of the memory allocation.
Warning
The tensor must not already be allocated. Otherwise calling the function will fail.

Implemented in CLTensorAllocator, and TensorAllocator.

◆ free()

virtual void free ( )
pure virtual

Interface to be implemented by the child class to free the allocated tensor.

Warning
The tensor must have been allocated previously. Otherwise calling the function will fail.

Implemented in CLTensorAllocator, and TensorAllocator.

◆ info() [1/2]

TensorInfo & info ( )

Return a reference to the tensor's metadata.

Returns
Reference to the tensor's metadata.

Definition at line 46 of file ITensorAllocator.cpp.

Referenced by TensorAllocator::allocate(), CLTensorAllocator::allocate(), TensorAllocator::free(), CLTensorAllocator::free(), TensorAllocator::import_memory(), CLTensorAllocator::import_memory(), Tensor::info(), CLTensor::info(), TensorAllocator::init(), and TensorAllocator::~TensorAllocator().

47 {
48  return (_info_external != nullptr) ? *_info_external : _info_owned;
49 }

◆ info() [2/2]

const TensorInfo & info ( ) const

Return a constant reference to the tensor's metadata.

Returns
Constant reference to the tensor's metadata.

Definition at line 51 of file ITensorAllocator.cpp.

52 {
53  return (_info_external != nullptr) ? *_info_external : _info_owned;
54 }

◆ init()

void init ( const TensorInfo input,
size_t  alignment = 0 
)

◆ operator=() [1/2]

ITensorAllocator& operator= ( const ITensorAllocator )
default

Allow instances of this class to be copied.

Referenced by TensorAllocator::operator=().

◆ operator=() [2/2]

ITensorAllocator& operator= ( ITensorAllocator &&  )
default

Allow instances of this class to be moved.

◆ soft_init()

void soft_init ( TensorInfo input,
size_t  alignment = 0 
)

Initialize a tensor based with a reference TensorInfo.

Note
ITensorAllocator won't own the TensorInfo thus these need to out-live
Parameters
[in]inputTensorInfo object containing the description of the tensor to initialize.
[in]alignmentAlignment in bytes that the underlying base pointer should comply with.

Definition at line 40 of file ITensorAllocator.cpp.

References ITensorAllocator::alignment(), and arm_compute::test::validation::input.

Referenced by CLAuxTensorHandler::CLAuxTensorHandler(), CpuAuxTensorHandler::CpuAuxTensorHandler(), and CpuGemmConv2d::run().

41 {
42  _info_external = &input;
43  _alignment = alignment;
44 }
size_t alignment() const
Return underlying&#39;s tensor buffer alignment.

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