mirror of
https://github.com/Qortal/Brooklyn.git
synced 2025-02-21 06:35:53 +00:00
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
//
|
|
// 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
|