ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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 112 of file MemoryPlanner.h.

Constructor & Destructor Documentation

◆ WICPlanner()

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

Definition at line 107 of file MemoryPlanner.cc.

108 : _initialized(false), _capacity(0), _mem_plans(), _live_operands(), _interference_graph(),
109 _operands()
110{
111 // DO NOTHING
112}

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 132 of file MemoryPlanner.h.

133 {
134 if (!_initialized)
135 buildMemoryPlans();
136 return _capacity;
137 }

◆ 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 114 of file MemoryPlanner.cc.

115{
116 _operands.emplace(size, ind);
117 _interference_graph[ind].insert(_interference_graph[ind].end(), _live_operands.cbegin(),
118 _live_operands.cend());
119 for (const auto &live_operand : _live_operands)
120 {
121 _interference_graph[live_operand].emplace_back(ind);
122 }
123 _live_operands.emplace(ind);
124
125 VERBOSE(WIC_PLANNER) << "claim(" << ind << "): [" << size << "sz]" << std::endl;
126}
#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 194 of file MemoryPlanner.cc.

195{
196 if (!_initialized)
197 buildMemoryPlans();
198 return _mem_plans;
199}

◆ 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 128 of file MemoryPlanner.cc.

129{
130 _live_operands.erase(ind);
131 VERBOSE(WIC_PLANNER) << "release(" << ind << ")" << std::endl;
132}

References VERBOSE.


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