ArmNN
 20.02
ClTensorHandle Class Reference

#include <ClTensorHandle.hpp>

Inheritance diagram for ClTensorHandle:
IClTensorHandle IAclTensorHandle ITensorHandle

Public Member Functions

 ClTensorHandle (const TensorInfo &tensorInfo)
 
 ClTensorHandle (const TensorInfo &tensorInfo, DataLayout dataLayout)
 
arm_compute::CLTensor & GetTensor () override
 
arm_compute::CLTensor const & GetTensor () const override
 
virtual void Allocate () override
 Indicate to the memory manager that this resource is no longer active. More...
 
virtual void Manage () override
 Indicate to the memory manager that this resource is active. More...
 
virtual const void * Map (bool blocking=true) const override
 Map the tensor data for access. More...
 
virtual void Unmap () const override
 Unmap the tensor data. More...
 
virtual ITensorHandleGetParent () const override
 Get the parent tensor if this is a subtensor. More...
 
virtual arm_compute::DataType GetDataType () const override
 
virtual void SetMemoryGroup (const std::shared_ptr< arm_compute::IMemoryGroup > &memoryGroup) override
 
TensorShape GetStrides () const override
 Get the strides for each dimension ordered from largest to smallest where the smallest value is the same as the size of a single element in the tensor. More...
 
TensorShape GetShape () const override
 Get the number of elements for each dimension ordered from slowest iterating dimension to fastest iterating dimension. More...
 
- Public Member Functions inherited from ITensorHandle
virtual ~ITensorHandle ()
 
void * Map (bool blocking=true)
 Map the tensor data for access. More...
 
void Unmap ()
 Unmap the tensor data that was previously mapped with call to Map(). More...
 
virtual unsigned int GetImportFlags () const
 Get flags describing supported import sources. More...
 
virtual bool Import (void *memory, MemorySource source)
 Import externally allocated memory. More...
 

Detailed Description

Definition at line 34 of file ClTensorHandle.hpp.

Constructor & Destructor Documentation

◆ ClTensorHandle() [1/2]

ClTensorHandle ( const TensorInfo tensorInfo)
inline

Definition at line 37 of file ClTensorHandle.hpp.

38  {
39  armnn::armcomputetensorutils::BuildArmComputeTensor(m_Tensor, tensorInfo);
40  }

◆ ClTensorHandle() [2/2]

ClTensorHandle ( const TensorInfo tensorInfo,
DataLayout  dataLayout 
)
inline

Definition at line 42 of file ClTensorHandle.hpp.

43  {
44  armnn::armcomputetensorutils::BuildArmComputeTensor(m_Tensor, tensorInfo, dataLayout);
45  }

Member Function Documentation

◆ Allocate()

virtual void Allocate ( )
inlineoverridevirtual

Indicate to the memory manager that this resource is no longer active.

This is used to compute overlapping lifetimes of resources.

Implements ITensorHandle.

Definition at line 49 of file ClTensorHandle.hpp.

49 {armnn::armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_Tensor);}

◆ GetDataType()

virtual arm_compute::DataType GetDataType ( ) const
inlineoverridevirtual

Implements IClTensorHandle.

Definition at line 67 of file ClTensorHandle.hpp.

68  {
69  return m_Tensor.info()->data_type();
70  }

◆ GetParent()

virtual ITensorHandle* GetParent ( ) const
inlineoverridevirtual

Get the parent tensor if this is a subtensor.

Returns
a pointer to the parent tensor. Otherwise nullptr if not a subtensor.

Implements ITensorHandle.

Definition at line 65 of file ClTensorHandle.hpp.

65 { return nullptr; }

◆ GetShape()

TensorShape GetShape ( ) const
inlineoverridevirtual

Get the number of elements for each dimension ordered from slowest iterating dimension to fastest iterating dimension.

Returns
a TensorShape filled with the number of elements for each dimension.

Implements ITensorHandle.

Definition at line 82 of file ClTensorHandle.hpp.

83  {
84  return armcomputetensorutils::GetShape(m_Tensor.info()->tensor_shape());
85  }

◆ GetStrides()

TensorShape GetStrides ( ) const
inlineoverridevirtual

Get the strides for each dimension ordered from largest to smallest where the smallest value is the same as the size of a single element in the tensor.

Returns
a TensorShape filled with the strides for each dimension

Implements ITensorHandle.

Definition at line 77 of file ClTensorHandle.hpp.

78  {
79  return armcomputetensorutils::GetStrides(m_Tensor.info()->strides_in_bytes());
80  }

◆ GetTensor() [1/2]

arm_compute::CLTensor& GetTensor ( )
inlineoverridevirtual

Implements IClTensorHandle.

Definition at line 47 of file ClTensorHandle.hpp.

47 { return m_Tensor; }

◆ GetTensor() [2/2]

arm_compute::CLTensor const& GetTensor ( ) const
inlineoverridevirtual

Implements IClTensorHandle.

Definition at line 48 of file ClTensorHandle.hpp.

48 { return m_Tensor; }

◆ Manage()

virtual void Manage ( )
inlineoverridevirtual

Indicate to the memory manager that this resource is active.

This is used to compute overlapping lifetimes of resources.

Implements ITensorHandle.

Definition at line 51 of file ClTensorHandle.hpp.

52  {
53  assert(m_MemoryGroup != nullptr);
54  m_MemoryGroup->manage(&m_Tensor);
55  }

◆ Map()

virtual const void* Map ( bool  blocking = true) const
inlineoverridevirtual

Map the tensor data for access.

Parameters
blockinghint to block the calling thread until all other accesses are complete. (backend dependent)
Returns
pointer to the first element of the mapped data.

Implements ITensorHandle.

Definition at line 57 of file ClTensorHandle.hpp.

58  {
59  const_cast<arm_compute::CLTensor*>(&m_Tensor)->map(blocking);
60  return static_cast<const void*>(m_Tensor.buffer() + m_Tensor.info()->offset_first_element_in_bytes());
61  }

◆ SetMemoryGroup()

virtual void SetMemoryGroup ( const std::shared_ptr< arm_compute::IMemoryGroup > &  memoryGroup)
inlineoverridevirtual

Implements IClTensorHandle.

Definition at line 72 of file ClTensorHandle.hpp.

73  {
74  m_MemoryGroup = boost::polymorphic_pointer_downcast<arm_compute::MemoryGroup>(memoryGroup);
75  }

◆ Unmap()

virtual void Unmap ( ) const
inlineoverridevirtual

Unmap the tensor data.

Implements ITensorHandle.

Definition at line 63 of file ClTensorHandle.hpp.

63 { const_cast<arm_compute::CLTensor*>(&m_Tensor)->unmap(); }

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