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 | /** Blob memory pool */ |
| 16 | class BlobMemoryPool : public IMemoryPool |
| 17 | { |
| 18 | public: |
| 19 | BlobMemoryPool(arm_compute::IAllocator* allocator, std::vector<size_t> blobSizes); |
| 20 | |
| 21 | ~BlobMemoryPool(); |
| 22 | |
| 23 | BlobMemoryPool(const BlobMemoryPool&) = delete; |
| 24 | |
| 25 | BlobMemoryPool& operator=(const BlobMemoryPool&) = delete; |
| 26 | |
| 27 | BlobMemoryPool(BlobMemoryPool&&) = default; |
| 28 | |
| 29 | BlobMemoryPool& operator=(BlobMemoryPool&&) = default; |
| 30 | |
| 31 | void acquire(arm_compute::MemoryMappings &handles) override; |
| 32 | void release(arm_compute::MemoryMappings &handles) override; |
| 33 | |
| 34 | arm_compute::MappingType mapping_type() const override; |
| 35 | |
| 36 | std::unique_ptr<arm_compute::IMemoryPool> duplicate() override; |
| 37 | |
| 38 | void AllocatePool() override; |
| 39 | void ReleasePool() override; |
| 40 | |
| 41 | private: |
| 42 | /// Allocator to use for internal allocation |
| 43 | arm_compute::IAllocator* m_Allocator; |
| 44 | |
| 45 | /// Vector holding all the memory blobs |
| 46 | std::vector<void*> m_Blobs; |
| 47 | |
| 48 | /// Sizes of each memory blob |
| 49 | std::vector<size_t> m_BlobSizes; |
| 50 | |
| 51 | /// Flag indicating whether memory has been allocated for the pool |
| 52 | bool m_MemoryAllocated; |
| 53 | }; |
| 54 | |
| 55 | } // namespace armnn |