ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::basic::MemoryManager Class Reference

#include <MemoryManager.h>

Public Member Functions

 MemoryManager ()
 
 MemoryManager (const std::string)
 
virtual ~MemoryManager ()=default
 
void allocate (void)
 
uint8_t * getBuffer (const ir::OperandIndex &ind) const
 
void deallocate (void)
 
void claimPlan (const ir::OperandIndex &ind, uint32_t size)
 
void releasePlan (const ir::OperandIndex &ind)
 

Protected Attributes

std::unordered_map< ir::OperandIndex, Block_tensor_mem_map
 
std::shared_ptr< IMemoryPlanner< ir::OperandIndex > > _mem_planner
 
std::shared_ptr< Allocator_mem_alloc
 

Detailed Description

Definition at line 34 of file MemoryManager.h.

Constructor & Destructor Documentation

◆ MemoryManager() [1/2]

onert::backend::basic::MemoryManager::MemoryManager ( )

Definition at line 32 of file MemoryManager.cc.

32 : _mem_planner{createMemoryPlanner()}
33{
34 // DO NOTHING
35}
std::shared_ptr< IMemoryPlanner< ir::OperandIndex > > _mem_planner

◆ MemoryManager() [2/2]

onert::backend::basic::MemoryManager::MemoryManager ( const std::string  planner_id)

Definition at line 37 of file MemoryManager.cc.

38 : _mem_planner{createMemoryPlanner(planner_id)}
39{
40 // DO NOTHING
41}

◆ ~MemoryManager()

virtual onert::backend::basic::MemoryManager::~MemoryManager ( )
virtualdefault

References getBuffer().

Member Function Documentation

◆ allocate()

void onert::backend::basic::MemoryManager::allocate ( void  )

Definition at line 62 of file MemoryManager.cc.

63{
64 _mem_alloc = std::make_shared<basic::Allocator>(_mem_planner->capacity());
65 assert(_mem_alloc->base());
66}
std::shared_ptr< Allocator > _mem_alloc

References _mem_alloc, and _mem_planner.

◆ claimPlan()

void onert::backend::basic::MemoryManager::claimPlan ( const ir::OperandIndex ind,
uint32_t  size 
)

Definition at line 55 of file MemoryManager.cc.

56{
57 _mem_planner->claim(ind, size);
58}
int32_t size[5]
Definition Slice.cpp:35

References _mem_planner, onert::backend::basic::IMemoryPlanner< Index >::claim(), and size.

◆ deallocate()

void onert::backend::basic::MemoryManager::deallocate ( void  )
inline

Definition at line 43 of file MemoryManager.h.

43{ _mem_alloc->release(); }

References _mem_alloc.

◆ getBuffer()

uint8_t * onert::backend::basic::MemoryManager::getBuffer ( const ir::OperandIndex ind) const

Definition at line 68 of file MemoryManager.cc.

69{
70 assert(_mem_planner->memory_plans().find(ind) != _mem_planner->memory_plans().end());
71 const auto &mem_blk = _mem_planner->memory_plans().at(ind);
72 return _mem_alloc->base() + mem_blk.offset;
73}

References _mem_alloc, and _mem_planner.

Referenced by ~MemoryManager().

◆ releasePlan()

void onert::backend::basic::MemoryManager::releasePlan ( const ir::OperandIndex ind)

Definition at line 60 of file MemoryManager.cc.

60{ _mem_planner->release(ind); }

References _mem_planner.

Field Documentation

◆ _mem_alloc

std::shared_ptr<Allocator> onert::backend::basic::MemoryManager::_mem_alloc
protected

◆ _mem_planner

std::shared_ptr<IMemoryPlanner<ir::OperandIndex> > onert::backend::basic::MemoryManager::_mem_planner
protected

◆ _tensor_mem_map

std::unordered_map<ir::OperandIndex, Block> onert::backend::basic::MemoryManager::_tensor_mem_map
protected

Definition at line 53 of file MemoryManager.h.


The documentation for this class was generated from the following files: