ArmNN
 20.05
ScopedCpuTensorHandle Class Reference

#include <CpuTensorHandle.hpp>

Inheritance diagram for ScopedCpuTensorHandle:
CpuTensorHandle ConstCpuTensorHandle ITensorHandle

Public Member Functions

 ScopedCpuTensorHandle (const TensorInfo &tensorInfo)
 
 ScopedCpuTensorHandle (const ConstTensor &tensor)
 
 ScopedCpuTensorHandle (const ConstCpuTensorHandle &tensorHandle)
 
 ScopedCpuTensorHandle (const ScopedCpuTensorHandle &other)
 
ScopedCpuTensorHandleoperator= (const ScopedCpuTensorHandle &other)
 
 ~ScopedCpuTensorHandle ()
 
virtual void Allocate () override
 Indicate to the memory manager that this resource is no longer active. More...
 
- Public Member Functions inherited from CpuTensorHandle
template<typename T >
T * GetTensor () const
 
template<>
void * GetTensor () const
 
template<>
void * GetTensor () const
 
- Public Member Functions inherited from ConstCpuTensorHandle
template<typename T >
const T * GetConstTensor () const
 
const TensorInfoGetTensorInfo () const
 
virtual void Manage () override
 Indicate to the memory manager that this resource is 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...
 
template<>
const void * GetConstTensor () const
 
template<>
const void * GetConstTensor () const
 
- 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...
 

Additional Inherited Members

- Protected Member Functions inherited from CpuTensorHandle
 CpuTensorHandle (const TensorInfo &tensorInfo)
 
void SetMemory (void *mem)
 
- Protected Member Functions inherited from ConstCpuTensorHandle
 ConstCpuTensorHandle (const TensorInfo &tensorInfo)
 
void SetConstMemory (const void *mem)
 

Detailed Description

Definition at line 106 of file CpuTensorHandle.hpp.

Constructor & Destructor Documentation

◆ ScopedCpuTensorHandle() [1/4]

ScopedCpuTensorHandle ( const TensorInfo tensorInfo)
explicit

Definition at line 55 of file CpuTensorHandle.cpp.

56 : CpuTensorHandle(tensorInfo)
57 {
58 }
CpuTensorHandle(const TensorInfo &tensorInfo)

◆ ScopedCpuTensorHandle() [2/4]

ScopedCpuTensorHandle ( const ConstTensor tensor)
explicit

Definition at line 60 of file CpuTensorHandle.cpp.

References BaseTensor< MemoryType >::GetMemoryArea(), and BaseTensor< MemoryType >::GetNumBytes().

61 : ScopedCpuTensorHandle(tensor.GetInfo())
62 {
63  CopyFrom(tensor.GetMemoryArea(), tensor.GetNumBytes());
64 }
ScopedCpuTensorHandle(const TensorInfo &tensorInfo)

◆ ScopedCpuTensorHandle() [3/4]

ScopedCpuTensorHandle ( const ConstCpuTensorHandle tensorHandle)
explicit

Definition at line 66 of file CpuTensorHandle.cpp.

References ConstCpuTensorHandle::GetConstTensor(), TensorInfo::GetNumBytes(), and ConstCpuTensorHandle::GetTensorInfo().

67 : ScopedCpuTensorHandle(tensorHandle.GetTensorInfo())
68 {
69  CopyFrom(tensorHandle.GetConstTensor<void>(), tensorHandle.GetTensorInfo().GetNumBytes());
70 }
ScopedCpuTensorHandle(const TensorInfo &tensorInfo)

◆ ScopedCpuTensorHandle() [4/4]

Definition at line 72 of file CpuTensorHandle.cpp.

73 : CpuTensorHandle(other.GetTensorInfo())
74 {
75  CopyFrom(other);
76 }
CpuTensorHandle(const TensorInfo &tensorInfo)

◆ ~ScopedCpuTensorHandle()

Definition at line 86 of file CpuTensorHandle.cpp.

87 {
88  ::operator delete(GetTensor<void>());
89 }

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.

Implements ITensorHandle.

Definition at line 91 of file CpuTensorHandle.cpp.

References ARMNN_ASSERT, TensorInfo::GetNumBytes(), CpuTensorHandle::GetTensor(), ConstCpuTensorHandle::GetTensorInfo(), and CpuTensorHandle::SetMemory().

92 {
93  if (GetTensor<void>() == nullptr)
94  {
95  SetMemory(::operator new(GetTensorInfo().GetNumBytes()));
96  }
97  else
98  {
99  throw InvalidArgumentException("CpuTensorHandle::Allocate Trying to allocate a CpuTensorHandle"
100  "that already has allocated memory.");
101  }
102 }
void SetMemory(void *mem)
const TensorInfo & GetTensorInfo() const

◆ operator=()

ScopedCpuTensorHandle & operator= ( const ScopedCpuTensorHandle other)

Definition at line 78 of file CpuTensorHandle.cpp.

References CpuTensorHandle::SetMemory().

79 {
80  ::operator delete(GetTensor<void>());
81  SetMemory(nullptr);
82  CopyFrom(other);
83  return *this;
84 }
void SetMemory(void *mem)

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