ArmNN
 24.08
BaseMemoryManager Class Referenceabstract

#include <BaseMemoryManager.hpp>

Inheritance diagram for BaseMemoryManager:
[legend]
Collaboration diagram for BaseMemoryManager:
[legend]

Public Types

enum  MemoryAffinity { Buffer, Offset }
 

Public Member Functions

 BaseMemoryManager ()
 
virtual ~BaseMemoryManager ()
 
void Acquire () override
 
void Release () override
 
 BaseMemoryManager (std::shared_ptr< arm_compute::IAllocator > alloc, MemoryAffinity memoryAffinity)
 
std::shared_ptr< arm_compute::MemoryManagerOnDemand > & GetIntraLayerManager ()
 
std::shared_ptr< arm_compute::MemoryManagerOnDemand > & GetInterLayerManager ()
 
std::shared_ptr< arm_compute::IMemoryGroup > & GetInterLayerMemoryGroup ()
 
- Public Member Functions inherited from IMemoryManager
virtual ~IMemoryManager ()
 

Protected Member Functions

std::shared_ptr< arm_compute::MemoryManagerOnDemand > CreateArmComputeMemoryManager (MemoryAffinity memoryAffinity)
 
virtual std::shared_ptr< arm_compute::IMemoryGroup > CreateMemoryGroup (const std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)=0
 
- Protected Member Functions inherited from IMemoryManager
 IMemoryManager ()
 

Protected Attributes

std::shared_ptr< arm_compute::IAllocator > m_Allocator
 
std::shared_ptr< arm_compute::MemoryManagerOnDemand > m_IntraLayerMemoryMgr
 
std::shared_ptr< arm_compute::MemoryManagerOnDemand > m_InterLayerMemoryMgr
 
std::shared_ptr< arm_compute::IMemoryGroup > m_InterLayerMemoryGroup
 

Detailed Description

Definition at line 24 of file BaseMemoryManager.hpp.

Member Enumeration Documentation

◆ MemoryAffinity

enum MemoryAffinity
strong
Enumerator
Buffer 
Offset 

Definition at line 27 of file BaseMemoryManager.hpp.

28  {
29  Buffer,
30  Offset
31  };

Constructor & Destructor Documentation

◆ BaseMemoryManager() [1/2]

BaseMemoryManager ( )
inline

Definition at line 33 of file BaseMemoryManager.hpp.

33 { }

◆ ~BaseMemoryManager()

virtual ~BaseMemoryManager ( )
inlinevirtual

Definition at line 34 of file BaseMemoryManager.hpp.

34 { }

◆ BaseMemoryManager() [2/2]

BaseMemoryManager ( std::shared_ptr< arm_compute::IAllocator >  alloc,
MemoryAffinity  memoryAffinity 
)

Member Function Documentation

◆ Acquire()

void Acquire ( )
overridevirtual

Implements IMemoryManager.

Definition at line 48 of file BaseMemoryManager.cpp.

49 {
50  static const size_t s_NumPools = 1;
51 
52  // Allocate memory pools for intra-layer memory manager
53  m_IntraLayerMemoryMgr->populate(*m_Allocator, s_NumPools);
54 
55  // Allocate memory pools for inter-layer memory manager
56  m_InterLayerMemoryMgr->populate(*m_Allocator, s_NumPools);
57 
58  // Acquire inter-layer memory group. NOTE: This has to come after allocating the pools
59  m_InterLayerMemoryGroup->acquire();
60 }

References BaseMemoryManager::m_Allocator, BaseMemoryManager::m_InterLayerMemoryGroup, BaseMemoryManager::m_InterLayerMemoryMgr, and BaseMemoryManager::m_IntraLayerMemoryMgr.

◆ CreateArmComputeMemoryManager()

std::shared_ptr< arm_compute::MemoryManagerOnDemand > CreateArmComputeMemoryManager ( MemoryAffinity  memoryAffinity)
protected

Definition at line 29 of file BaseMemoryManager.cpp.

30 {
31  std::shared_ptr<arm_compute::ILifetimeManager> lifetimeManager = nullptr;
32 
33  if (memoryAffinity == MemoryAffinity::Buffer)
34  {
35  lifetimeManager = std::make_shared<arm_compute::BlobLifetimeManager>();
36  }
37  else
38  {
39  lifetimeManager = std::make_shared<arm_compute::OffsetLifetimeManager>();
40  }
41 
42  auto poolManager = std::make_shared<arm_compute::PoolManager>();
43  auto memoryManager = std::make_shared<arm_compute::MemoryManagerOnDemand>(lifetimeManager, poolManager);
44 
45  return memoryManager;
46 }

References BaseMemoryManager::Buffer.

Referenced by BaseMemoryManager::BaseMemoryManager().

◆ CreateMemoryGroup()

virtual std::shared_ptr<arm_compute::IMemoryGroup> CreateMemoryGroup ( const std::shared_ptr< arm_compute::MemoryManagerOnDemand > &  memoryManager)
protectedpure virtual

Implemented in ClMemoryManager, and NeonMemoryManager.

◆ GetInterLayerManager()

std::shared_ptr<arm_compute::MemoryManagerOnDemand>& GetInterLayerManager ( )
inline

Definition at line 43 of file BaseMemoryManager.hpp.

43 { return m_InterLayerMemoryMgr; }

References BaseMemoryManager::m_InterLayerMemoryMgr.

◆ GetInterLayerMemoryGroup()

std::shared_ptr<arm_compute::IMemoryGroup>& GetInterLayerMemoryGroup ( )
inline

Definition at line 44 of file BaseMemoryManager.hpp.

44 { return m_InterLayerMemoryGroup; }

References BaseMemoryManager::m_InterLayerMemoryGroup.

◆ GetIntraLayerManager()

std::shared_ptr<arm_compute::MemoryManagerOnDemand>& GetIntraLayerManager ( )
inline

Definition at line 42 of file BaseMemoryManager.hpp.

42 { return m_IntraLayerMemoryMgr; }

References BaseMemoryManager::m_IntraLayerMemoryMgr.

◆ Release()

void Release ( )
overridevirtual

Implements IMemoryManager.

Definition at line 62 of file BaseMemoryManager.cpp.

63 {
64  // Release inter-layer memory group. NOTE: This has to come before releasing the pools
65  m_InterLayerMemoryGroup->release();
66 
67  // Release memory pools managed by intra-layer memory manager
68  m_IntraLayerMemoryMgr->clear();
69 
70  // Release memory pools managed by inter-layer memory manager
71  m_InterLayerMemoryMgr->clear();
72 }

References BaseMemoryManager::m_InterLayerMemoryGroup, BaseMemoryManager::m_InterLayerMemoryMgr, and BaseMemoryManager::m_IntraLayerMemoryMgr.

Member Data Documentation

◆ m_Allocator

std::shared_ptr<arm_compute::IAllocator> m_Allocator
protected

◆ m_InterLayerMemoryGroup

std::shared_ptr<arm_compute::IMemoryGroup> m_InterLayerMemoryGroup
protected

◆ m_InterLayerMemoryMgr

◆ m_IntraLayerMemoryMgr

std::shared_ptr<arm_compute::MemoryManagerOnDemand> m_IntraLayerMemoryMgr
protected

The documentation for this class was generated from the following files:
armnn::BaseMemoryManager::m_InterLayerMemoryGroup
std::shared_ptr< arm_compute::IMemoryGroup > m_InterLayerMemoryGroup
Definition: BaseMemoryManager.hpp:50
armnn::BaseMemoryManager::m_Allocator
std::shared_ptr< arm_compute::IAllocator > m_Allocator
Definition: BaseMemoryManager.hpp:47
armnn::BaseMemoryManager::CreateArmComputeMemoryManager
std::shared_ptr< arm_compute::MemoryManagerOnDemand > CreateArmComputeMemoryManager(MemoryAffinity memoryAffinity)
Definition: BaseMemoryManager.cpp:29
armnn::BaseMemoryManager::m_InterLayerMemoryMgr
std::shared_ptr< arm_compute::MemoryManagerOnDemand > m_InterLayerMemoryMgr
Definition: BaseMemoryManager.hpp:49
armnn::BaseMemoryManager::MemoryAffinity::Buffer
@ Buffer
armnn::Offset
unsigned int Offset(const TensorShape &shape, unsigned int batch, unsigned int height, unsigned int width, unsigned int channels, const DataLayoutIndexed &dataLayout)
Definition: BatchToSpaceNd.cpp:15
armnn::BaseMemoryManager::m_IntraLayerMemoryMgr
std::shared_ptr< arm_compute::MemoryManagerOnDemand > m_IntraLayerMemoryMgr
Definition: BaseMemoryManager.hpp:48
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition: Exceptions.hpp:210