aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/backends/ICustomAllocator.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 /include/armnn/backends/ICustomAllocator.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 'include/armnn/backends/ICustomAllocator.hpp')
-rw-r--r--include/armnn/backends/ICustomAllocator.hpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/include/armnn/backends/ICustomAllocator.hpp b/include/armnn/backends/ICustomAllocator.hpp
index 1d4df0cb86..92cbcc2641 100644
--- a/include/armnn/backends/ICustomAllocator.hpp
+++ b/include/armnn/backends/ICustomAllocator.hpp
@@ -7,6 +7,7 @@
#include <cstddef>
#include <memory>
+#include <armnn/MemorySources.hpp>
namespace armnn
{
@@ -23,13 +24,20 @@ public:
* @param[in] alignment Alignment that the returned pointer should comply with
*
* @return A pointer to the allocated memory
+ * The returned pointer must be host write accessible
*/
- virtual void *allocate(size_t size, size_t alignment) = 0;
- /** Interface to be implemented by the child class to free the allocated tensor */
- virtual void free(void *ptr) = 0;
+ virtual void* allocate(size_t size, size_t alignment) = 0;
- // Utility Function to define the Custom Memory Allocators capabilities
- virtual bool SupportsProtectedMemory() = 0;
+ /** 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
+ // Unsupported types are:
+ // MemorySource::DmaBuf
+ // MemorySource::DmaBufProtected
+ virtual armnn::MemorySource GetMemorySourceType() = 0;
};
} // namespace armnn \ No newline at end of file