aboutsummaryrefslogtreecommitdiff
path: root/include/armnnTestUtils/MockMemoryManager.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/armnnTestUtils/MockMemoryManager.hpp')
-rw-r--r--include/armnnTestUtils/MockMemoryManager.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/armnnTestUtils/MockMemoryManager.hpp b/include/armnnTestUtils/MockMemoryManager.hpp
new file mode 100644
index 0000000000..38cd56747a
--- /dev/null
+++ b/include/armnnTestUtils/MockMemoryManager.hpp
@@ -0,0 +1,59 @@
+//
+// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <armnn/backends/IMemoryManager.hpp>
+
+#include <forward_list>
+#include <vector>
+
+namespace armnn
+{
+
+// An implementation of IMemoryManager to be used with MockTensorHandle
+class MockMemoryManager : public IMemoryManager
+{
+public:
+ MockMemoryManager();
+ virtual ~MockMemoryManager();
+
+ class Pool;
+
+ Pool* Manage(unsigned int numBytes);
+
+ void Allocate(Pool* pool);
+
+ void* GetPointer(Pool* pool);
+
+ void Acquire() override;
+ void Release() override;
+
+ class Pool
+ {
+ public:
+ Pool(unsigned int numBytes);
+ ~Pool();
+
+ void Acquire();
+ void Release();
+
+ void* GetPointer();
+
+ void Reserve(unsigned int numBytes);
+
+ private:
+ unsigned int m_Size;
+ void* m_Pointer;
+ };
+
+private:
+ MockMemoryManager(const MockMemoryManager&) = delete; // Noncopyable
+ MockMemoryManager& operator=(const MockMemoryManager&) = delete; // Noncopyable
+
+ std::forward_list<Pool> m_Pools;
+ std::vector<Pool*> m_FreePools;
+};
+
+} // namespace armnn