ArmNN
 24.08
RefTensorHandleDecorator Class Reference

#include <RefTensorHandle.hpp>

Inheritance diagram for RefTensorHandleDecorator:
[legend]
Collaboration diagram for RefTensorHandleDecorator:
[legend]

Public Member Functions

 RefTensorHandleDecorator (const TensorInfo &tensorInfo, const RefTensorHandle &parent)
 
 ~RefTensorHandleDecorator ()=default
 
virtual void Manage () override
 Indicate to the memory manager that this resource is active. More...
 
virtual void Allocate () override
 Indicate to the memory manager that this resource is no longer active. More...
 
virtual ITensorHandleGetParent () const override
 Get the parent tensor if this is a subtensor. More...
 
virtual const void * Map (bool) const override
 Map the tensor data for access. More...
 
virtual void Unmap () const override
 Unmap the tensor data. More...
 
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...
 
const TensorInfoGetTensorInfo () const
 
virtual MemorySourceFlags GetImportFlags () const override
 Get flags describing supported import sources. More...
 
virtual bool Import (void *memory, MemorySource source) override
 Import externally allocated memory. More...
 
virtual bool CanBeImported (void *memory, MemorySource source) override
 Implementations must determine if this memory block can be imported. More...
 
virtual std::shared_ptr< ITensorHandleDecorateTensorHandle (const TensorInfo &tensorInfo) override
 Returns a decorated version of this TensorHandle allowing us to override the TensorInfo for it. More...
 
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...
 
void CopyOutTo (void *) const override
 Testing support to be able to verify and set tensor data content. More...
 
void CopyInFrom (const void *) override
 
void Unimport () override
 Unimport externally allocated memory. More...
 
virtual const void * Map (bool blocking=true) const=0
 Map the tensor data for access. More...
 
void * Map (bool blocking=true)
 Map the tensor data for access. More...
 
- Public Member Functions inherited from RefTensorHandle
 RefTensorHandle (const TensorInfo &tensorInfo, std::shared_ptr< RefMemoryManager > &memoryManager)
 
 RefTensorHandle (const TensorInfo &tensorInfo)
 
 RefTensorHandle (const TensorInfo &tensorInfo, const RefTensorHandle &parent)
 
 ~RefTensorHandle ()
 
const TensorInfoGetTensorInfo () const
 
virtual const void * Map (bool blocking=true) const=0
 Map the tensor data for access. More...
 
void * Map (bool blocking=true)
 Map the tensor data for access. 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...
 

Detailed Description

Definition at line 84 of file RefTensorHandle.hpp.

Constructor & Destructor Documentation

◆ RefTensorHandleDecorator()

RefTensorHandleDecorator ( const TensorInfo tensorInfo,
const RefTensorHandle parent 
)

Definition at line 174 of file RefTensorHandle.cpp.

175 : RefTensorHandle(tensorInfo)
176 , m_TensorInfo(tensorInfo)
177 , m_Parent(parent)
178 {
179 }

◆ ~RefTensorHandleDecorator()

Member Function Documentation

◆ Allocate()

void Allocate ( )
overridevirtual

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

This is used to compute overlapping lifetimes of resources.

Reimplemented from RefTensorHandle.

Definition at line 185 of file RefTensorHandle.cpp.

186 {
187 }

◆ CanBeImported()

bool CanBeImported ( void *  memory,
MemorySource  source 
)
overridevirtual

Implementations must determine if this memory block can be imported.

This might be based on alignment or memory source type.

Returns
true if this memory can be imported.
false by default, cannot be imported.

Reimplemented from RefTensorHandle.

Definition at line 204 of file RefTensorHandle.cpp.

205 {
206  return false;
207 }

◆ CopyInFrom()

void CopyInFrom ( const void *  )
inlineoverridevirtual

Reimplemented from RefTensorHandle.

Definition at line 146 of file RefTensorHandle.hpp.

147  {};

◆ CopyOutTo()

void CopyOutTo ( void *  ) const
inlineoverridevirtual

Testing support to be able to verify and set tensor data content.

Reimplemented from RefTensorHandle.

Definition at line 143 of file RefTensorHandle.hpp.

144  {};

◆ DecorateTensorHandle()

std::shared_ptr< ITensorHandle > DecorateTensorHandle ( const TensorInfo tensorInfo)
overridevirtual

Returns a decorated version of this TensorHandle allowing us to override the TensorInfo for it.

Parameters
tensorInfothe overidden TensorInfo.

Reimplemented from RefTensorHandle.

Definition at line 209 of file RefTensorHandle.cpp.

210 {
211  return nullptr;
212 }

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Get flags describing supported import sources.

Reimplemented from RefTensorHandle.

Definition at line 194 of file RefTensorHandle.cpp.

195 {
196  return static_cast<MemorySourceFlags>(MemorySource::Malloc);
197 }

References armnn::Malloc.

◆ 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.

Reimplemented from RefTensorHandle.

Definition at line 95 of file RefTensorHandle.hpp.

96  {
97  return nullptr;
98  }

◆ 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.

Reimplemented from RefTensorHandle.

Definition at line 111 of file RefTensorHandle.hpp.

112  {
113  return m_TensorInfo.GetShape();
114  }

References TensorInfo::GetShape().

◆ 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

Reimplemented from RefTensorHandle.

Definition at line 106 of file RefTensorHandle.hpp.

107  {
108  return GetUnpaddedTensorStrides(m_TensorInfo);
109  }

References armnn::GetUnpaddedTensorStrides().

◆ GetTensorInfo()

const TensorInfo& GetTensorInfo ( ) const
inline

Definition at line 116 of file RefTensorHandle.hpp.

117  {
118  return m_TensorInfo;
119  }

◆ Import()

bool Import ( void *  memory,
MemorySource  source 
)
overridevirtual

Import externally allocated memory.

Parameters
memorybase address of the memory being imported.
sourcesource of the allocation for the memory being imported.
Returns
true on success or false on failure

Reimplemented from RefTensorHandle.

Definition at line 199 of file RefTensorHandle.cpp.

200 {
201  return false;
202 }

◆ Manage()

void Manage ( )
overridevirtual

Indicate to the memory manager that this resource is active.

This is used to compute overlapping lifetimes of resources.

Reimplemented from RefTensorHandle.

Definition at line 181 of file RefTensorHandle.cpp.

182 {
183 }

◆ Map() [1/4]

void* Map
inline

Map the tensor data for access.

Must be paired with call to Unmap().

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.

Definition at line 44 of file ITensorHandle.hpp.

45  {
46  return const_cast<void*>(static_cast<const ITensorHandle*>(this)->Map(blocking));
47  }

◆ Map() [2/4]

void* Map ( bool  blocking = true)
inline

Map the tensor data for access.

Must be paired with call to Unmap().

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.

Definition at line 131 of file RefTensorHandle.hpp.

132  {
133  return const_cast<void*>(static_cast<const ITensorHandle*>(this)->Map(blocking));
134  }

References RefTensorHandleDecorator::Map().

◆ Map() [3/4]

virtual const void* Map

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.

◆ Map() [4/4]

const void * Map ( bool  blocking) const
overridevirtual

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.

Reimplemented from RefTensorHandle.

Definition at line 189 of file RefTensorHandle.cpp.

190 {
191  return m_Parent.Map(unused);
192 }

References RefTensorHandle::Map().

Referenced by RefTensorHandleDecorator::Map().

◆ Unimport()

void Unimport ( )
inlineoverridevirtual

Unimport externally allocated memory.

Reimplemented from ITensorHandle.

Definition at line 150 of file RefTensorHandle.hpp.

151  {};

◆ Unmap() [1/2]

void Unmap ( )
inline

Unmap the tensor data that was previously mapped with call to Map().

Definition at line 137 of file RefTensorHandle.hpp.

138  {
139  return static_cast<const ITensorHandle*>(this)->Unmap();
140  }

References RefTensorHandleDecorator::Unmap().

◆ Unmap() [2/2]

virtual void Unmap ( ) const
inlineoverridevirtual

Unmap the tensor data.

Reimplemented from RefTensorHandle.

Definition at line 103 of file RefTensorHandle.hpp.

104  {}

Referenced by RefTensorHandleDecorator::Unmap().


The documentation for this class was generated from the following files:
armnn::MemorySource::Malloc
@ Malloc
armnn::RefTensorHandleDecorator::Map
virtual const void * Map(bool) const override
Map the tensor data for access.
Definition: RefTensorHandle.cpp:189
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::GetUnpaddedTensorStrides
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
Definition: TensorHandle.cpp:15
armnn::RefTensorHandle::RefTensorHandle
RefTensorHandle(const TensorInfo &tensorInfo, std::shared_ptr< RefMemoryManager > &memoryManager)
Definition: RefTensorHandle.cpp:11
armnn::RefTensorHandleDecorator::Unmap
virtual void Unmap() const override
Unmap the tensor data.
Definition: RefTensorHandle.hpp:103
armnn::RefTensorHandle::Map
virtual const void * Map(bool) const override
Map the tensor data for access.
Definition: RefTensorHandle.cpp:77
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:193