blob: 05a6ec0f87a4b2c6ae30481408a8111be2071415 [file] [log] [blame]
Francis Murtagh9270d9e2022-08-12 13:54:17 +01001//
2// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
7#include <armnn/backends/IMemoryManager.hpp>
8
9#include <forward_list>
10#include <vector>
11
12namespace armnn
13{
14
15// An implementation of IMemoryManager to be used with RefTensorHandle
16class TosaRefMemoryManager : public IMemoryManager
17{
18public:
19 TosaRefMemoryManager();
20 virtual ~TosaRefMemoryManager();
21
22 class Pool;
23
24 Pool* Manage(unsigned int numBytes);
25
26 void Allocate(Pool *pool);
27
28 void* GetPointer(Pool *pool);
29
30 void Acquire() override;
31 void Release() override;
32
33 class Pool
34 {
35 public:
36 Pool(unsigned int numBytes);
37 ~Pool();
38
39 void Acquire();
40 void Release();
41
42 void* GetPointer();
43
44 void Reserve(unsigned int numBytes);
45
46 private:
47 unsigned int m_Size;
48 void* m_Pointer;
49 };
50
51private:
52 TosaRefMemoryManager(const TosaRefMemoryManager&) = delete; // Noncopyable
53 TosaRefMemoryManager& operator=(const TosaRefMemoryManager&) = delete; // Noncopyable
54
55 std::forward_list<Pool> m_Pools;
56 std::vector<Pool*> m_FreePools;
57};
58
59}