ArmNN
 21.08
ICustomAllocator.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <cstddef>
9 #include <memory>
10 #include <armnn/MemorySources.hpp>
11 
12 namespace armnn
13 {
14 /** Custom Allocator interface */
16 {
17 public:
18  /** Default virtual destructor. */
19  virtual ~ICustomAllocator() = default;
20 
21  /** Interface to be implemented by the child class to allocate bytes
22  *
23  * @param[in] size Size to allocate
24  * @param[in] alignment Alignment that the returned pointer should comply with
25  *
26  * @return A pointer to the allocated memory
27  * The returned pointer must be host write accessible
28  */
29  virtual void* allocate(size_t size, size_t alignment) = 0;
30 
31  /** Interface to be implemented by the child class to free the allocated bytes */
32  virtual void free(void* ptr) = 0;
33 
34  // Used to specify what type of memory is being allocated by this allocator.
35  // Supported types are:
36  // MemorySource::Malloc
37  // MemorySource::DmaBuf
38  // Unsupported types are:
39  // MemorySource::DmaBufProtected
41 
42 };
43 } // namespace armnn
Custom Allocator interface.
virtual ~ICustomAllocator()=default
Default virtual destructor.
virtual void free(void *ptr)=0
Interface to be implemented by the child class to free the allocated bytes.
Copyright (c) 2021 ARM Limited and Contributors.
virtual armnn::MemorySource GetMemorySourceType()=0
MemorySource
Define the Memory Source to reduce copies.
Definition: Types.hpp:198
virtual void * allocate(size_t size, size_t alignment)=0
Interface to be implemented by the child class to allocate bytes.