telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include "IMemoryPool.hpp" |
| 8 | |
Aron Virginas-Tar | f9aeef0 | 2018-10-12 15:18:03 +0100 | [diff] [blame] | 9 | #include <arm_compute/runtime/IAllocator.h> |
| 10 | #include <arm_compute/runtime/Types.h> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | class OffsetMemoryPool : public IMemoryPool |
| 16 | { |
| 17 | public: |
| 18 | OffsetMemoryPool(arm_compute::IAllocator* allocator, size_t blobSize); |
| 19 | |
| 20 | ~OffsetMemoryPool(); |
| 21 | |
| 22 | OffsetMemoryPool(const OffsetMemoryPool&) = delete; |
| 23 | |
| 24 | OffsetMemoryPool& operator=(const OffsetMemoryPool&) = delete; |
| 25 | |
| 26 | OffsetMemoryPool(OffsetMemoryPool&&) = default; |
| 27 | |
| 28 | OffsetMemoryPool& operator=(OffsetMemoryPool &&) = default; |
| 29 | |
| 30 | void acquire(arm_compute::MemoryMappings& handles) override; |
| 31 | void release(arm_compute::MemoryMappings& handles) override; |
| 32 | |
| 33 | arm_compute::MappingType mapping_type() const override; |
| 34 | |
| 35 | std::unique_ptr<arm_compute::IMemoryPool> duplicate() override; |
| 36 | |
| 37 | void AllocatePool() override; |
| 38 | void ReleasePool() override; |
| 39 | |
| 40 | private: |
| 41 | /// Allocator to use for internal allocation |
| 42 | arm_compute::IAllocator* m_Allocator; |
| 43 | |
| 44 | /// Memory blob |
| 45 | void* m_Blob; |
| 46 | |
| 47 | /// Size of the allocated memory blob |
| 48 | size_t m_BlobSize; |
| 49 | |
| 50 | /// Flag indicating whether memory has been allocated for the pool |
| 51 | bool m_MemoryAllocated; |
| 52 | }; |
| 53 | |
| 54 | } // namespace armnn |