24.02
|
Go to the documentation of this file.
12 m_TensorInfo(tensorInfo),
13 m_MemoryManager(memoryManager),
15 m_UnmanagedMemory(nullptr),
16 m_ImportedMemory(nullptr),
22 : m_TensorInfo(tensorInfo),
24 m_UnmanagedMemory(nullptr),
25 m_ImportedMemory(nullptr),
31 : m_TensorInfo(tensorInfo),
32 m_MemoryManager(parent.m_MemoryManager),
33 m_Pool(parent.m_Pool),
34 m_UnmanagedMemory(parent.m_UnmanagedMemory),
35 m_ImportedMemory(parent.m_ImportedMemory),
42 ::operator
delete(m_UnmanagedMemory);
48 ARMNN_ASSERT_MSG(!m_UnmanagedMemory,
"RefTensorHandle::Manage() called after Allocate()");
52 m_Pool = m_MemoryManager->Manage(m_TensorInfo.
GetNumBytes());
58 if (!m_UnmanagedMemory)
63 m_UnmanagedMemory = ::operator
new(m_TensorInfo.
GetNumBytes());
67 m_MemoryManager->Allocate(m_Pool);
73 "that already has allocated memory.");
82 void* RefTensorHandle::GetPointer()
const
86 return m_ImportedMemory;
88 else if (m_UnmanagedMemory)
90 return m_UnmanagedMemory;
94 return m_MemoryManager->GetPointer(m_Pool);
98 throw NullPointerException(
"RefTensorHandle::GetPointer called on unmanaged, unallocated tensor handle");
102 void RefTensorHandle::CopyOutTo(
void* dest)
const
104 const void* src = GetPointer();
107 throw NullPointerException(
"TensorHandle::CopyOutTo called with a null src pointer");
111 throw NullPointerException(
"TensorHandle::CopyOutTo called with a null dest pointer");
116 void RefTensorHandle::CopyInFrom(
const void* src)
118 void* dest = GetPointer();
121 throw NullPointerException(
"RefTensorHandle::CopyInFrom called with a null dest pointer");
125 throw NullPointerException(
"RefTensorHandle::CopyInFrom called with a null src pointer");
142 m_ImportedMemory =
nullptr;
146 m_ImportedMemory = memory;
158 if (
reinterpret_cast<uintptr_t
>(memory) % alignment)
169 auto decorated = std::make_shared<RefTensorHandleDecorator>(tensorInfo, *
this);
170 m_Decorated.emplace_back(decorated);
176 , m_TensorInfo(tensorInfo)
191 return m_Parent.
Map(unused);
unsigned int GetNumBytes() const
virtual const void * Map(bool) const override
Map the tensor data for access.
virtual bool CanBeImported(void *memory, MemorySource source) override
Implementations must determine if this memory block can be imported.
virtual MemorySourceFlags GetImportFlags() const override
Get flags describing supported import sources.
unsigned int MemorySourceFlags
virtual void Manage() override
Indicate to the memory manager that this resource is active.
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
#define ARMNN_ASSERT_MSG(COND, MSG)
virtual bool Import(void *memory, MemorySource source) override
Import externally allocated memory.
const TensorInfo & GetTensorInfo() const
virtual std::shared_ptr< ITensorHandle > DecorateTensorHandle(const TensorInfo &tensorInfo) override
Returns a decorated version of this TensorHandle allowing us to override the TensorInfo for it.
virtual std::shared_ptr< ITensorHandle > DecorateTensorHandle(const TensorInfo &tensorInfo) override
Returns a decorated version of this TensorHandle allowing us to override the TensorInfo for it.
RefTensorHandle(const TensorInfo &tensorInfo, std::shared_ptr< RefMemoryManager > &memoryManager)
constexpr unsigned int GetDataTypeSize(DataType dataType)
DataType GetDataType() const
virtual const void * Map(bool) const override
Map the tensor data for access.
MemorySource
Define the Memory Source to reduce copies.
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
Copyright (c) 2021 ARM Limited and Contributors.
virtual bool Import(void *memory, MemorySource source) override
Import externally allocated memory.
virtual void Manage() override
Indicate to the memory manager that this resource is active.
RefTensorHandleDecorator(const TensorInfo &tensorInfo, const RefTensorHandle &parent)
virtual bool CanBeImported(void *memory, MemorySource source) override
Implementations must determine if this memory block can be imported.
virtual MemorySourceFlags GetImportFlags() const override
Get flags describing supported import sources.