ArmNN
 24.02
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
54  m_IntraLayerMemoryMgr->populate(*m_Allocator, s_NumPools);
55 
56  // Allocate memory pools for inter-layer memory manager
58  m_InterLayerMemoryMgr->populate(*m_Allocator, s_NumPools);
59 
60  // Acquire inter-layer memory group. NOTE: This has to come after allocating the pools
62  m_InterLayerMemoryGroup->acquire();
63 }

References ARMNN_ASSERT, 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 65 of file BaseMemoryManager.cpp.

66 {
67  // Release inter-layer memory group. NOTE: This has to come before releasing the pools
69  m_InterLayerMemoryGroup->release();
70 
71  // Release memory pools managed by intra-layer memory manager
73  m_IntraLayerMemoryMgr->clear();
74 
75  // Release memory pools managed by inter-layer memory manager
77  m_InterLayerMemoryMgr->clear();
78 }

References ARMNN_ASSERT, 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_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
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