ArmNN
 24.02
ICustomAllocator Class Referenceabstract

Custom Allocator interface. More...

#include <ICustomAllocator.hpp>

Inheritance diagram for ICustomAllocator:
[legend]

Public Member Functions

virtual ~ICustomAllocator ()=default
 Default virtual destructor. More...
 
virtual void * allocate (size_t size, size_t alignment)=0
 Interface to be implemented by the child class to allocate bytes. More...
 
virtual void free (void *ptr)=0
 Interface to be implemented by the child class to free the allocated bytes. More...
 
virtual armnn::MemorySource GetMemorySourceType ()=0
 Used to specify what type of memory is being allocated by this allocator. More...
 
virtual void * GetMemoryRegionAtOffset (void *buffer, size_t offset, size_t alignment=0)
 Interface that may be implemented to allow retrieval of Memory Region from allocated buffer at a certain offset. More...
 

Detailed Description

Custom Allocator interface.

Examples
CustomMemoryAllocatorSample.cpp.

Definition at line 16 of file ICustomAllocator.hpp.

Constructor & Destructor Documentation

◆ ~ICustomAllocator()

virtual ~ICustomAllocator ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ allocate()

virtual void* allocate ( size_t  size,
size_t  alignment 
)
pure virtual

Interface to be implemented by the child class to allocate bytes.

Parameters
[in]sizeSize to allocate
[in]alignmentAlignment that the returned pointer should comply with
Returns
A pointer to the allocated memory The returned pointer must be host write accessible

Implemented in GpuFsaBackendDefaultAllocator, DefaultAllocator, and ClBackendDefaultAllocator.

Examples
CustomMemoryAllocatorSample.cpp.

◆ free()

virtual void free ( void *  ptr)
pure virtual

Interface to be implemented by the child class to free the allocated bytes.

Implemented in GpuFsaBackendDefaultAllocator, ClBackendDefaultAllocator, and DefaultAllocator.

Examples
CustomMemoryAllocatorSample.cpp.

◆ GetMemoryRegionAtOffset()

virtual void* GetMemoryRegionAtOffset ( void *  buffer,
size_t  offset,
size_t  alignment = 0 
)
inlinevirtual

Interface that may be implemented to allow retrieval of Memory Region from allocated buffer at a certain offset.

Reimplemented in GpuFsaBackendDefaultAllocator, ClBackendDefaultAllocator, and DefaultAllocator.

Definition at line 46 of file ICustomAllocator.hpp.

47  {
48  IgnoreUnused(offset);
49  IgnoreUnused(alignment);
50  IgnoreUnused(buffer);
51  throw armnn::Exception(
52  "ICustomerAllocator::GetMemoryRegionAtOffset(): This function should be overridden in subclass.");
53  }

References armnn::IgnoreUnused().

◆ GetMemorySourceType()

virtual armnn::MemorySource GetMemorySourceType ( )
pure virtual

Used to specify what type of memory is being allocated by this allocator.

Supported types are: MemorySource::Malloc MemorySource::DmaBuf MemorySource::DmaBufProtected

Implemented in GpuFsaBackendDefaultAllocator, ClBackendDefaultAllocator, and DefaultAllocator.

Examples
CustomMemoryAllocatorSample.cpp.

The documentation for this class was generated from the following file:
armnn::Exception
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14