aboutsummaryrefslogtreecommitdiff
path: root/src/backends/aclCommon/BaseMemoryManager.hpp
diff options
context:
space:
mode:
authorJan Eilers <jan.eilers@arm.com>2021-07-22 13:17:04 +0100
committerDavid Monahan <david.monahan@arm.com>2021-08-10 16:35:33 +0100
commitc1c872f12797ef6fe52c4589113e7efc353e56eb (patch)
tree911320c5306f9d2273ee76201806bfb12cbe4cd3 /src/backends/aclCommon/BaseMemoryManager.hpp
parentf487486c843a38fced90229923433d09f99fc2e5 (diff)
downloadarmnn-c1c872f12797ef6fe52c4589113e7efc353e56eb.tar.gz
Adds CustomAllocator interface and Sample App
* Updates the runtime options with a CustomAllocatorMap which allows to define a CustomAllocator for specific backends * Change IBackendInternal interface to use a shared pointer to a custom allocator * Update ClBackend.hpp/cpp to use the CustomAllocator * Adds an example application and unit test which uses a CustomAllocator for GpuAcc * Refactor of the interface to use MemorySource instead of the user Mapping cl_mem directly * Modify the BackendRegistry to also hold a registry of CustomAllocators * BackendRegistry Deregister will also deregister any allocators associated with that backend id * set_global_allocator within the BaseMemoryManager so that it always matches the currently used allocator Signed-off-by: Jan Eilers <jan.eilers@arm.com> Change-Id: I156d819686021865f4375e6cb7a5c5dec8fee9e8 Signed-off-by: David Monahan <david.monahan@arm.com>
Diffstat (limited to 'src/backends/aclCommon/BaseMemoryManager.hpp')
-rw-r--r--src/backends/aclCommon/BaseMemoryManager.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backends/aclCommon/BaseMemoryManager.hpp b/src/backends/aclCommon/BaseMemoryManager.hpp
index e80abf0edd..e3ffd188a1 100644
--- a/src/backends/aclCommon/BaseMemoryManager.hpp
+++ b/src/backends/aclCommon/BaseMemoryManager.hpp
@@ -15,6 +15,7 @@
#include <arm_compute/runtime/IAllocator.h>
#include <arm_compute/runtime/IMemoryGroup.h>
#include <arm_compute/runtime/MemoryManagerOnDemand.h>
+#include <arm_compute/runtime/CL/CLTensorAllocator.h>
#endif
namespace armnn
@@ -36,14 +37,14 @@ public:
void Release() override;
#if defined(ARMCOMPUTENEON_ENABLED) || defined(ARMCOMPUTECL_ENABLED)
- BaseMemoryManager(std::unique_ptr<arm_compute::IAllocator> alloc, MemoryAffinity memoryAffinity);
+ BaseMemoryManager(std::shared_ptr<arm_compute::IAllocator> alloc, MemoryAffinity memoryAffinity);
std::shared_ptr<arm_compute::MemoryManagerOnDemand>& GetIntraLayerManager() { return m_IntraLayerMemoryMgr; }
std::shared_ptr<arm_compute::MemoryManagerOnDemand>& GetInterLayerManager() { return m_InterLayerMemoryMgr; }
std::shared_ptr<arm_compute::IMemoryGroup>& GetInterLayerMemoryGroup() { return m_InterLayerMemoryGroup; }
protected:
- std::unique_ptr<arm_compute::IAllocator> m_Allocator;
+ std::shared_ptr<arm_compute::IAllocator> m_Allocator;
std::shared_ptr<arm_compute::MemoryManagerOnDemand> m_IntraLayerMemoryMgr;
std::shared_ptr<arm_compute::MemoryManagerOnDemand> m_InterLayerMemoryMgr;
std::shared_ptr<arm_compute::IMemoryGroup> m_InterLayerMemoryGroup;
@@ -81,9 +82,10 @@ public:
ClMemoryManager() {}
virtual ~ClMemoryManager() {}
- ClMemoryManager(std::unique_ptr<arm_compute::IAllocator> alloc)
+ ClMemoryManager(std::shared_ptr<arm_compute::IAllocator> alloc)
: BaseMemoryManager(std::move(alloc), MemoryAffinity::Buffer)
{
+ arm_compute::CLTensorAllocator::set_global_allocator(alloc.get());
m_InterLayerMemoryGroup = CreateMemoryGroup(m_InterLayerMemoryMgr);
}