ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter::ModuleLoader Class Reference

#include <ModuleLoader.h>

Public Member Functions

 ModuleLoader (const luci::Module *module, RuntimeModule *runtime_module, RuntimeToIR &runtime_to_ir, std::unordered_map< const loco::Node *, Tensor * > &node_to_tensor, IMemoryManager *memory_manager)
 
void load ()
 

Static Public Member Functions

static void load (RuntimeModule *runtime_module, MemoryManager *memory_manager, const char *model_data_raw, bool dealloc_input)
 

Detailed Description

Definition at line 31 of file ModuleLoader.h.

Constructor & Destructor Documentation

◆ ModuleLoader()

luci_interpreter::ModuleLoader::ModuleLoader ( const luci::Module module,
RuntimeModule runtime_module,
RuntimeToIR runtime_to_ir,
std::unordered_map< const loco::Node *, Tensor * > &  node_to_tensor,
IMemoryManager memory_manager 
)

Definition at line 24 of file ModuleLoader.cpp.

28 : _module(module), _runtime_module(runtime_module), _runtime_to_ir(runtime_to_ir),
29 _node_to_tensor(node_to_tensor), _memory_manager(memory_manager)
30{
31}

Member Function Documentation

◆ load() [1/2]

void luci_interpreter::ModuleLoader::load ( )

Definition at line 33 of file ModuleLoader.cpp.

34{
35 // Runtime graphs have to be created in advance, because they will be needed during the loading
36 // process for control flow nodes.
37 for (size_t i = 0; i < _module->size(); ++i)
38 {
39 _graph_to_runtime_graph.emplace(_module->graph(i), _runtime_module->addGraph(_memory_manager));
40 }
41 for (size_t i = 0; i < _module->size(); ++i)
42 {
43 const loco::Graph *graph = _module->graph(i);
44 RuntimeGraph *runtime_graph = _graph_to_runtime_graph.at(graph);
45 GraphLoader loader(graph, runtime_graph, _runtime_to_ir, _graph_to_runtime_graph,
46 _node_to_tensor, _memory_manager);
47 loader.loadTensors();
48 loader.initInputOutputTensors();
49 loader.loadOperators();
50 }
51}
A neural network graph.
Definition Graph.h:161
size_t size(void) const
Definition Module.h:44
loco::Graph * graph(void) const
provide main graph
Definition Module.cpp:32
RuntimeGraph * addGraph(IMemoryManager *memory_manager)

References luci_interpreter::RuntimeModule::addGraph(), luci::Module::graph(), luci_interpreter::GraphLoader::initInputOutputTensors(), luci_interpreter::GraphLoader::loadOperators(), luci_interpreter::GraphLoader::loadTensors(), and luci::Module::size().

Referenced by luci_interpreter::Interpreter::Interpreter(), luci_interpreter::Interpreter::Interpreter(), and luci_interpreter::Interpreter::Interpreter().

◆ load() [2/2]

void luci_interpreter::ModuleLoader::load ( RuntimeModule runtime_module,
MemoryManager memory_manager,
const char *  model_data_raw,
bool  dealloc_input 
)
static

Definition at line 24 of file ModuleLoader.cpp.

26{
27 const circle::Model *model = circle::GetModel(model_data_raw);
28
29 CircleReader &reader = runtime_module->getCircleReader();
30 if (!reader.parse(model))
31 assert(false && "Error during parse");
32
33 for (size_t i = 0; i < reader.num_subgraph(); ++i)
34 {
35 if (!reader.select_subgraph(i))
36 assert(false && "Error during select subgraph");
37 runtime_module->addGraph(memory_manager);
38
39#ifndef USE_STATIC_ALLOC
40 auto *runtime_graph = runtime_module->getRuntimeGraphAt(i);
41 // For Dynamic memory manager we can use inplace optimization
42 GraphLoader::checkInplaceOps(&reader, runtime_graph);
43#endif // USE_STATIC_ALLOC
44 }
45
46 // For Dynamic Memory manager we build memory allocate/deallocate plan and then configure kernels.
47 // For Static Memory manager we only configure kernels.
48 for (size_t i = 0; i < reader.num_subgraph(); ++i)
49 {
50 auto *runtime_graph = runtime_module->getRuntimeGraphAt(i);
51#ifdef USE_STATIC_ALLOC
52 runtime_graph->configure_kernels();
53#else
54 runtime_graph->configure(dealloc_input);
55#endif // USE_STATIC_ALLOC
56 }
57
58 // Select main subgraph
59 reader.select_subgraph(0);
60}
static void checkInplaceOps(CircleReader *reader, RuntimeGraph *runtime_graph)

References luci_interpreter::RuntimeModule::addGraph(), luci_interpreter::GraphLoader::checkInplaceOps(), luci_interpreter::RuntimeGraph::configure(), luci_interpreter::RuntimeModule::getCircleReader(), luci_interpreter::RuntimeModule::getRuntimeGraphAt(), luci::CircleReader::num_subgraph(), luci::CircleReader::parse(), and luci::CircleReader::select_subgraph().


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