Skip to content

Commit

Permalink
[luci-interpreter] Split interpreter constructor in two (Samsung#8074)
Browse files Browse the repository at this point in the history
This PR eliminates default value for memory_manager in interpreter constructors.

ONE-DCO-1.0-Signed-off-by: Alexander Efimov <[email protected]>
  • Loading branch information
Alexander Efimov authored Dec 1, 2021
1 parent 6615c45 commit df85b4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class ExecutionObserver
class Interpreter
{
public:
explicit Interpreter(const luci::Module *module, IMemoryManager *memory_manager = nullptr);
explicit Interpreter(const luci::Module *module);

explicit Interpreter(const luci::Module *module, IMemoryManager *memory_manager);

~Interpreter();

Expand Down
26 changes: 17 additions & 9 deletions compiler/luci-interpreter/src/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,30 @@ class EventNotifierImpl final : public EventNotifier

} // namespace

Interpreter::Interpreter(const luci::Module *module)
{
_runtime_to_ir = std::make_unique<RuntimeToIR>();
_event_notifier = std::make_unique<EventNotifierImpl>(*_runtime_to_ir, _observers);
_runtime_module = std::make_unique<RuntimeModule>(_event_notifier.get());

_default_memory_manager = std::make_unique<SimpleMemoryManager>();
_memory_manager = _default_memory_manager.get();

ModuleLoader loader(module, _runtime_module.get(), *_runtime_to_ir, _node_to_tensor,
_memory_manager);
loader.load();
}

Interpreter::Interpreter(const luci::Module *module,
luci_interpreter::IMemoryManager *memory_manager)
{
assert(memory_manager && "Use Interpreter::Interpreter(module) constructor instead");

_runtime_to_ir = std::make_unique<RuntimeToIR>();
_event_notifier = std::make_unique<EventNotifierImpl>(*_runtime_to_ir, _observers);
_runtime_module = std::make_unique<RuntimeModule>(_event_notifier.get());

if (memory_manager == nullptr)
{
_default_memory_manager = std::make_unique<SimpleMemoryManager>();
_memory_manager = _default_memory_manager.get();
}
else
{
_memory_manager = memory_manager;
}
_memory_manager = memory_manager;

ModuleLoader loader(module, _runtime_module.get(), *_runtime_to_ir, _node_to_tensor,
_memory_manager);
Expand Down

0 comments on commit df85b4f

Please sign in to comment.