ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 114 of file MemoryPlanner.h.

Constructor & Destructor Documentation

◆ WICPlanner()

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

Definition at line 110 of file MemoryPlanner.cc.

111 : _initialized(false), _capacity(0), _mem_plans(), _live_indices(), _interference_graph(),
112 _indices()
113{
114 // DO NOTHING
115}

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

138 {
139 if (!_initialized)
140 buildMemoryPlans();
141 return _capacity;
142 }

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

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

199{
200 if (!_initialized)
201 buildMemoryPlans();
202 return _mem_plans;
203}

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

132{
133 _live_indices.erase(ind);
134 VERBOSE(WIC_PLANNER) << "release(" << ind << ")" << std::endl;
135}

References VERBOSE.


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