ArmNN
 24.02
RefMemoryManager.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
9 #include <forward_list>
10 #include <vector>
11 
12 namespace armnn
13 {
14 
15 // An implementation of IMemoryManager to be used with RefTensorHandle
17 {
18 public:
20  virtual ~RefMemoryManager();
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 
51 private:
52  RefMemoryManager(const RefMemoryManager&) = delete; // Noncopyable
53  RefMemoryManager& operator=(const RefMemoryManager&) = delete; // Noncopyable
54 
55  std::forward_list<Pool> m_Pools;
56  std::vector<Pool*> m_FreePools;
57 };
58 
59 }
armnn::RefMemoryManager::RefMemoryManager
RefMemoryManager()
Definition: RefMemoryManager.cpp:14
armnn::RefMemoryManager::Release
void Release() override
Definition: RefMemoryManager.cpp:55
armnn::RefMemoryManager::GetPointer
void * GetPointer(Pool *pool)
Definition: RefMemoryManager.cpp:42
armnn::RefMemoryManager::Manage
Pool * Manage(unsigned int numBytes)
Definition: RefMemoryManager.cpp:20
armnn::RefMemoryManager::Pool::Acquire
void Acquire()
Definition: RefMemoryManager.cpp:88
armnn::RefMemoryManager::Pool::Release
void Release()
Definition: RefMemoryManager.cpp:94
armnn::RefMemoryManager::Acquire
void Acquire() override
Definition: RefMemoryManager.cpp:47
armnn::RefMemoryManager::Pool
Definition: RefMemoryManager.hpp:33
armnn::RefMemoryManager::Pool::Pool
Pool(unsigned int numBytes)
Definition: RefMemoryManager.cpp:63
armnn::IMemoryManager
Definition: IMemoryManager.hpp:12
armnn::RefMemoryManager
Definition: RefMemoryManager.hpp:16
armnn::RefMemoryManager::Pool::GetPointer
void * GetPointer()
Definition: RefMemoryManager.cpp:76
armnn::RefMemoryManager::Pool::~Pool
~Pool()
Definition: RefMemoryManager.cpp:68
armnn::RefMemoryManager::Allocate
void Allocate(Pool *pool)
Definition: RefMemoryManager.cpp:36
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::RefMemoryManager::Pool::Reserve
void Reserve(unsigned int numBytes)
Definition: RefMemoryManager.cpp:82
armnn::RefMemoryManager::~RefMemoryManager
virtual ~RefMemoryManager()
Definition: RefMemoryManager.cpp:17
IMemoryManager.hpp