From e8d7ccb1a18b5c39ecf17fb063fcc50baacc74b3 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Thu, 14 Oct 2021 17:30:24 +0100 Subject: IVGCVSW-6310 Update ICustomAllocator and add GetDefaultAllocator function to backends Signed-off-by: Francis Murtagh Change-Id: If2879e8a82692285e7fa3f4d09abd608ca28de12 --- include/armnn/backends/IBackendInternal.hpp | 20 ++++++++++++++------ include/armnn/backends/ICustomAllocator.hpp | 26 ++++++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) (limited to 'include/armnn') diff --git a/include/armnn/backends/IBackendInternal.hpp b/include/armnn/backends/IBackendInternal.hpp index f4fe678a5b..7500e35897 100644 --- a/include/armnn/backends/IBackendInternal.hpp +++ b/include/armnn/backends/IBackendInternal.hpp @@ -13,12 +13,12 @@ #include #include -#include "IBackendContext.hpp" -#include "armnn/backends/profiling/IBackendProfiling.hpp" -#include "armnn/backends/profiling/IBackendProfilingContext.hpp" -#include "IMemoryManager.hpp" -#include "ITensorHandleFactory.hpp" -#include "OptimizationViews.hpp" +#include +#include +#include +#include +#include +#include #include #include @@ -198,6 +198,14 @@ public: } return false; } + + /// Returns the default memory allocator for the backend + /// + /// \return - Returns unique pointer to the Default Allocator of the Backend + virtual std::unique_ptr GetDefaultAllocator() const + { + throw armnn::Exception("GetDefaultAllocator: Function has not been implemented in backend."); + } }; using IBackendInternalUniquePtr = std::unique_ptr; diff --git a/include/armnn/backends/ICustomAllocator.hpp b/include/armnn/backends/ICustomAllocator.hpp index 2cb5f41f78..eb8dfe1459 100644 --- a/include/armnn/backends/ICustomAllocator.hpp +++ b/include/armnn/backends/ICustomAllocator.hpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace armnn { @@ -31,13 +32,26 @@ public: /** Interface to be implemented by the child class to free the allocated bytes */ virtual void free(void* ptr) = 0; - // Used to specify what type of memory is being allocated by this allocator. - // Supported types are: - // MemorySource::Malloc - // MemorySource::DmaBuf - // Unsupported types are: - // MemorySource::DmaBufProtected + /** Used to specify what type of memory is being allocated by this allocator. + * Supported types are: + * MemorySource::Malloc + * MemorySource::DmaBuf + * Unsupported types are: + * MemorySource::DmaBufProtected + */ virtual armnn::MemorySource GetMemorySourceType() = 0; + /** Interface that may be implemented to allow retrieval of Memory Region + * from allocated buffer at a certain offset + */ + virtual void* GetMemoryRegionAtOffset(void* buffer, size_t offset, size_t alignment = 0) + { + IgnoreUnused(offset); + IgnoreUnused(alignment); + IgnoreUnused(buffer); + throw armnn::Exception( + "ICustomerAllocator::GetMemoryRegionAtOffset(): This function should be overridden in subclass."); + } + }; } // namespace armnn \ No newline at end of file -- cgit v1.2.1