ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::backend::basic::WICPlanner Class Reference

Class to plan memory by Weighted Interval Color algorithm. More...

#include <MemoryPlanner.h>

Collaboration diagram for onert::backend::basic::WICPlanner:

Public Member Functions

 WICPlanner ()
 
void claim (const ir::OperandIndex &, size_t) override
 Claim memory for operand by WIC algorithm.
 
void release (const ir::OperandIndex &) override
 Release memory for operand by WIC algorithm.
 
uint32_t capacity () override
 Get capacity for memory planning.
 
MemoryPlansmemory_plans () override
 Get MemoryPlans.
 
- Public Member Functions inherited from onert::backend::basic::IMemoryPlanner< ir::OperandIndex >
virtual ~IMemoryPlanner ()=default
 

Additional Inherited Members

- Public Types inherited from onert::backend::basic::IMemoryPlanner< ir::OperandIndex >
using MemoryPlans = std::unordered_map< ir::OperandIndex, Block >
 

Detailed Description

Class to plan memory by Weighted Interval Color algorithm.

Definition at line 108 of file MemoryPlanner.h.

Constructor & Destructor Documentation

◆ WICPlanner()

onert::backend::basic::WICPlanner::WICPlanner ( )

Definition at line 103 of file MemoryPlanner.cc.

104 : _initialized(false), _capacity(0), _mem_plans(), _live_operands(), _interference_graph(),
105 _operands()
106{
107 // DO NOTHING
108}

Member Function Documentation

◆ capacity()

uint32_t onert::backend::basic::WICPlanner::capacity ( )
inlineoverridevirtual

Get capacity for memory planning.

Returns
The value of capacity

Implements onert::backend::basic::IMemoryPlanner< ir::OperandIndex >.

Definition at line 128 of file MemoryPlanner.h.

129 {
130 if (!_initialized)
131 buildMemoryPlans();
132 return _capacity;
133 }

◆ claim()

void onert::backend::basic::WICPlanner::claim ( const ir::OperandIndex ind,
size_t  size 
)
overridevirtual

Claim memory for operand by WIC algorithm.

Parameters
[in]indexThe operand index
[in]sizeThe size of the memory

Implements onert::backend::basic::IMemoryPlanner< ir::OperandIndex >.

Definition at line 110 of file MemoryPlanner.cc.

111{
112 _operands.emplace(size, ind);
113 _interference_graph[ind].insert(_interference_graph[ind].end(), _live_operands.cbegin(),
114 _live_operands.cend());
115 for (const auto &live_operand : _live_operands)
116 {
117 _interference_graph[live_operand].emplace_back(ind);
118 }
119 _live_operands.emplace(ind);
120
121 VERBOSE(WIC_PLANNER) << "claim(" << ind << "): [" << size << "sz]" << std::endl;
122}
#define VERBOSE(name, lv)
Definition Log.h:71
ShapeIterator end(const Shape &s)
int32_t size[5]
Definition Slice.cpp:35

References size, and VERBOSE.

◆ memory_plans()

WICPlanner::MemoryPlans & onert::backend::basic::WICPlanner::memory_plans ( )
overridevirtual

Get MemoryPlans.

Returns
MemoryPlans

Implements onert::backend::basic::IMemoryPlanner< ir::OperandIndex >.

Definition at line 190 of file MemoryPlanner.cc.

191{
192 if (!_initialized)
193 buildMemoryPlans();
194 return _mem_plans;
195}

◆ release()

void onert::backend::basic::WICPlanner::release ( const ir::OperandIndex ind)
overridevirtual

Release memory for operand by WIC algorithm.

Parameters
[in]indexThe operand index

Implements onert::backend::basic::IMemoryPlanner< ir::OperandIndex >.

Definition at line 124 of file MemoryPlanner.cc.

125{
126 _live_operands.erase(ind);
127 VERBOSE(WIC_PLANNER) << "release(" << ind << ")" << std::endl;
128}

References VERBOSE.


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