ArmNN
 25.11
Loading...
Searching...
No Matches
MemoryManager.hpp
Go to the documentation of this file.
1//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
8
9namespace armnn
10{
12{
13 /// Pointer to @ICustomAllocator.
14 std::shared_ptr<ICustomAllocator> m_CustomAllocator{};
15 /// Value which the size of each buffer (actual data size + padding) has to be a multiple of.
16 size_t m_Alignment = 0 ;
17};
18
20{
21 /// Number of bytes the value is away from the @BufferStorage.m_Buffer.
22 size_t m_Offset{};
23 /// Identifier to be used by the @LoadedNetwork to order the tensors.
24 unsigned int m_OutputSlotId{};
25 /// Pointer to the tensor value.
26 void* m_Data = nullptr;
27};
28
30{
31 /// Vector of pointer to @TensorMemory.
32 std::vector<std::shared_ptr<TensorMemory>> m_TensorMemoryVector;
33 /// Total size of the buffer.
35 /// Pointer to the first element of the buffer.
36 void* m_Buffer = nullptr;
37};
38
40{
41public:
42 /// Initialization method to store in m_AllocatorBufferStoragePairVector all information needed.
43 /// @param[in] bufferStorageVector - Vector of BufferStorage.
44 /// @param[in] customAllocator - Pointer to ICustomAllocator.
45 /// @param[in] typeAlignment - Optional parameter. Value of which the size of each value has to be multiple of.
46 void StoreMemToAllocate(std::vector<BufferStorage> bufferStorageVector,
47 std::shared_ptr<ICustomAllocator> customAllocator,
48 size_t typeAlignment = 0);
49
50 /// Allocate the amount of memory indicated by m_BufferSize, and
51 /// point each m_Data to each correspondent Tensor so that they are m_Offset bytes separated.
52 void Allocate();
53
54 /// Deallocate memory
55 void Deallocate();
56
57private:
58 std::vector<std::pair<Allocator, std::vector<BufferStorage>>> m_AllocatorBufferStoragePairVector;
59};
60
61} // namespace armnn
void StoreMemToAllocate(std::vector< BufferStorage > bufferStorageVector, std::shared_ptr< ICustomAllocator > customAllocator, size_t typeAlignment=0)
Initialization method to store in m_AllocatorBufferStoragePairVector all information needed.
void Allocate()
Allocate the amount of memory indicated by m_BufferSize, and point each m_Data to each correspondent ...
void Deallocate()
Deallocate memory.
Copyright (c) 2021 ARM Limited and Contributors.
std::shared_ptr< ICustomAllocator > m_CustomAllocator
Pointer to @ICustomAllocator.
size_t m_Alignment
Value which the size of each buffer (actual data size + padding) has to be a multiple of.
std::vector< std::shared_ptr< TensorMemory > > m_TensorMemoryVector
Vector of pointer to @TensorMemory.
void * m_Buffer
Pointer to the first element of the buffer.
size_t m_BufferSize
Total size of the buffer.
unsigned int m_OutputSlotId
Identifier to be used by the @LoadedNetwork to order the tensors.
size_t m_Offset
Number of bytes the value is away from the @BufferStorage.m_Buffer.
void * m_Data
Pointer to the tensor value.