12 std::shared_ptr<SampleMemoryManager> &memoryManager)
13 : m_TensorInfo(tensorInfo),
14 m_MemoryManager(memoryManager),
16 m_UnmanagedMemory(nullptr),
25 : m_TensorInfo(tensorInfo),
26 m_MemoryManager(nullptr),
28 m_UnmanagedMemory(nullptr),
29 m_ImportFlags(importFlags),
42 ::operator
delete(m_UnmanagedMemory);
49 m_Pool = m_MemoryManager->Manage(m_TensorInfo.
GetNumBytes());
54 if (!m_UnmanagedMemory)
59 m_UnmanagedMemory = ::operator
new(m_TensorInfo.
GetNumBytes());
63 m_MemoryManager->Allocate(m_Pool);
69 "SampleTensorHandle that already has allocated "
79 void* SampleTensorHandle::GetPointer()
const
81 if (m_UnmanagedMemory)
83 return m_UnmanagedMemory;
87 return m_MemoryManager->GetPointer(m_Pool);
99 constexpr uintptr_t alignment =
sizeof(size_t);
100 if (
reinterpret_cast<uintptr_t
>(memory) % alignment)
105 m_UnmanagedMemory =
nullptr;
112 if (!m_Imported && !m_UnmanagedMemory)
114 m_UnmanagedMemory = memory;
120 if (!m_Imported && m_UnmanagedMemory)
128 m_UnmanagedMemory = memory;
137 void SampleTensorHandle::CopyOutTo(
void* dest)
const
139 const void* src = GetPointer();
142 throw armnn::Exception(
"SampleTensorHandle:CopyOutTo: Destination Ptr is null");
151 void SampleTensorHandle::CopyInFrom(
const void* src)
153 void* dest = GetPointer();
156 throw armnn::Exception(
"SampleTensorHandle:CopyInFrom: Source Ptr is null");
160 throw armnn::Exception(
"SampleTensorHandle:CopyInFrom: Destination Ptr is null");