Compute Library
 21.05
Allocator Class Referencefinal

Default malloc allocator implementation. More...

#include <Allocator.h>

Collaboration diagram for Allocator:
[legend]

Public Member Functions

 Allocator ()=default
 Default constructor. More...
 
void * allocate (size_t size, size_t alignment) 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 tensor. More...
 
std::unique_ptr< IMemoryRegionmake_region (size_t size, size_t alignment) override
 Create self-managed memory region. More...
 
- Public Member Functions inherited from IAllocator
virtual ~IAllocator ()=default
 Default virtual destructor. More...
 

Detailed Description

Default malloc allocator implementation.

Definition at line 36 of file Allocator.h.

Constructor & Destructor Documentation

◆ Allocator()

Allocator ( )
default

Default constructor.

Member Function Documentation

◆ allocate()

void * allocate ( size_t  size,
size_t  alignment 
)
overridevirtual

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

Implements IAllocator.

Definition at line 33 of file Allocator.cpp.

34 {
35  ARM_COMPUTE_UNUSED(alignment);
36  return ::operator new(size);
37 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

References ARM_COMPUTE_UNUSED.

◆ free()

void free ( void *  ptr)
overridevirtual

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

Implements IAllocator.

Definition at line 39 of file Allocator.cpp.

40 {
41  ::operator delete(ptr);
42 }

◆ make_region()

std::unique_ptr< IMemoryRegion > make_region ( size_t  size,
size_t  alignment 
)
overridevirtual

Create self-managed memory region.

Parameters
[in]sizeSize of the memory region
[in]alignmentAlignment of the memory region
Returns
The memory region object

Implements IAllocator.

Definition at line 44 of file Allocator.cpp.

45 {
46  return std::make_unique<MemoryRegion>(size, alignment);
47 }

The documentation for this class was generated from the following files: