ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::train::WICPlanner< Index > Class Template Reference

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

#include <MemoryPlanner.h>

Collaboration diagram for onert::backend::train::WICPlanner< Index >:

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

template<typename Index>
class onert::backend::train::WICPlanner< Index >

Class to plan memory by Weighted Interval Color algorithm.

Definition at line 118 of file MemoryPlanner.h.

Constructor & Destructor Documentation

◆ WICPlanner()

template<typename Index >
onert::backend::train::WICPlanner< Index >::WICPlanner ( )

Definition at line 114 of file MemoryPlanner.cc.

115 : _initialized(false), _capacity(0), _mem_plans(), _live_indices(), _interference_graph(),
116 _indices()
117{
118 // DO NOTHING
119}

Member Function Documentation

◆ capacity()

template<typename Index >
uint32_t onert::backend::train::WICPlanner< Index >::capacity ( )
inlineoverridevirtual

Get capacity for memory planning.

Returns
The value of capacity

Implements onert::backend::basic::IMemoryPlanner< Index >.

Definition at line 141 of file MemoryPlanner.h.

142 {
143 if (!_initialized)
144 buildMemoryPlans();
145 return _capacity;
146 }

◆ claim()

template<typename Index >
void onert::backend::train::WICPlanner< Index >::claim ( const Index &  ind,
size_t  size 
)
overridevirtual

Claim memory for tensor by WIC algorithm.

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

Implements onert::backend::basic::IMemoryPlanner< Index >.

Definition at line 121 of file MemoryPlanner.cc.

122{
123 _indices.emplace(size, ind);
124 _interference_graph[ind].insert(_interference_graph[ind].end(), _live_indices.cbegin(),
125 _live_indices.cend());
126 for (const auto &live_operand : _live_indices)
127 {
128 _interference_graph[live_operand].emplace_back(ind);
129 }
130 _live_indices.emplace(ind);
131
132 VERBOSE(WIC_PLANNER) << "claim(" << ind << "): [" << size << "sz]" << std::endl;
133}
#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()

template<typename Index >
WICPlanner< Index >::MemoryPlans & onert::backend::train::WICPlanner< Index >::memory_plans ( )
overridevirtual

Get MemoryPlans.

Returns
MemoryPlans

Implements onert::backend::basic::IMemoryPlanner< Index >.

Definition at line 202 of file MemoryPlanner.cc.

203{
204 if (!_initialized)
205 buildMemoryPlans();
206 return _mem_plans;
207}

◆ release()

template<typename Index >
void onert::backend::train::WICPlanner< Index >::release ( const Index &  ind)
overridevirtual

Release memory for tensor by WIC algorithm.

Parameters
[in]indexThe tensor index

Implements onert::backend::basic::IMemoryPlanner< Index >.

Definition at line 135 of file MemoryPlanner.cc.

136{
137 _live_indices.erase(ind);
138 VERBOSE(WIC_PLANNER) << "release(" << ind << ")" << std::endl;
139}

References VERBOSE.


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