ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ModuleLoader.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include "
ModuleLoader.h
"
18
19
#include "
GraphLoader.h
"
20
21
namespace
luci_interpreter
22
{
23
24
ModuleLoader::ModuleLoader
(
const
luci::Module
*module,
RuntimeModule
*runtime_module,
25
RuntimeToIR
&runtime_to_ir,
26
std::unordered_map<const loco::Node *, Tensor *> &node_to_tensor,
27
IMemoryManager
*memory_manager)
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
}
32
33
void
ModuleLoader::load
()
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
}
52
53
}
// namespace luci_interpreter
loco::Graph
A neural network graph.
Definition
Graph.h:161
luci::Module
Collection of 'loco::Graph's.
Definition
Module.h:33
luci::Module::size
size_t size(void) const
Definition
Module.h:44
luci::Module::graph
loco::Graph * graph(void) const
provide main graph
Definition
Module.cpp:32
luci_interpreter::GraphLoader
Definition
GraphLoader.h:32
luci_interpreter::GraphLoader::initInputOutputTensors
void initInputOutputTensors() const
Definition
GraphLoader.cpp:274
luci_interpreter::GraphLoader::loadOperators
void loadOperators()
Definition
GraphLoader.cpp:295
luci_interpreter::GraphLoader::loadTensors
void loadTensors()
Definition
GraphLoader.cpp:187
luci_interpreter::IMemoryManager
Definition
MemoryManager.h:27
luci_interpreter::ModuleLoader::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
ModuleLoader.cpp:24
luci_interpreter::ModuleLoader::load
void load()
Definition
ModuleLoader.cpp:33
luci_interpreter::RuntimeGraph
Definition
RuntimeGraph.h:33
luci_interpreter::RuntimeModule
Definition
RuntimeModule.h:31
luci_interpreter::RuntimeModule::addGraph
RuntimeGraph * addGraph(IMemoryManager *memory_manager)
Definition
RuntimeModule.h:37
luci_interpreter
Definition
BuddyMemoryManager.h:22
GraphLoader.h
ModuleLoader.h
luci_interpreter::RuntimeToIR
Definition
RuntimeToIR.h:31
compiler
luci-interpreter
src
loader
ModuleLoader.cpp
Generated by
1.9.8