ArmNN
 24.08
DefaultAllocator Class Reference

Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource) More...

#include <DefaultAllocator.hpp>

Inheritance diagram for DefaultAllocator:
[legend]
Collaboration diagram for DefaultAllocator:
[legend]

Public Member Functions

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

Detailed Description

Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource)

Definition at line 17 of file DefaultAllocator.hpp.

Constructor & Destructor Documentation

◆ DefaultAllocator()

DefaultAllocator ( )
default

Member Function Documentation

◆ allocate()

void* allocate ( size_t  size,
size_t  alignment = 0 
)
inlineoverridevirtual

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

Implements ICustomAllocator.

Definition at line 22 of file DefaultAllocator.hpp.

23  {
24  IgnoreUnused(alignment);
25  return ::operator new(size_t(size));
26  }

References armnn::IgnoreUnused().

◆ free()

void free ( void *  ptr)
inlineoverridevirtual

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

Implements ICustomAllocator.

Definition at line 28 of file DefaultAllocator.hpp.

29  {
30  ::operator delete(ptr);
31  }

◆ GetMemoryRegionAtOffset()

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

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

Reimplemented from ICustomAllocator.

Definition at line 38 of file DefaultAllocator.hpp.

39  {
40  IgnoreUnused(alignment);
41  return static_cast<char*>(buffer) + offset;
42  }

References armnn::IgnoreUnused().

◆ GetMemorySourceType()

armnn::MemorySource GetMemorySourceType ( )
inlineoverridevirtual

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

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

Implements ICustomAllocator.

Definition at line 33 of file DefaultAllocator.hpp.

34  {
36  }

References armnn::Malloc.


The documentation for this class was generated from the following file:
armnn::MemorySource::Malloc
@ Malloc
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14