From df85b4f9d023857dfb726626518e02995f8846d3 Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Wed, 1 Dec 2021 14:15:29 +0300 Subject: [PATCH] [luci-interpreter] Split interpreter constructor in two (#8074) This PR eliminates default value for memory_manager in interpreter constructors. ONE-DCO-1.0-Signed-off-by: Alexander Efimov --- .../include/luci_interpreter/Interpreter.h | 4 ++- compiler/luci-interpreter/src/Interpreter.cpp | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/compiler/luci-interpreter/include/luci_interpreter/Interpreter.h b/compiler/luci-interpreter/include/luci_interpreter/Interpreter.h index 7dee8a7f2de..75ecac4c779 100644 --- a/compiler/luci-interpreter/include/luci_interpreter/Interpreter.h +++ b/compiler/luci-interpreter/include/luci_interpreter/Interpreter.h @@ -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(); diff --git a/compiler/luci-interpreter/src/Interpreter.cpp b/compiler/luci-interpreter/src/Interpreter.cpp index 1b8792a6cd5..d9ff7681893 100644 --- a/compiler/luci-interpreter/src/Interpreter.cpp +++ b/compiler/luci-interpreter/src/Interpreter.cpp @@ -70,22 +70,30 @@ class EventNotifierImpl final : public EventNotifier } // namespace +Interpreter::Interpreter(const luci::Module *module) +{ + _runtime_to_ir = std::make_unique(); + _event_notifier = std::make_unique(*_runtime_to_ir, _observers); + _runtime_module = std::make_unique(_event_notifier.get()); + + _default_memory_manager = std::make_unique(); + _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(); _event_notifier = std::make_unique(*_runtime_to_ir, _observers); _runtime_module = std::make_unique(_event_notifier.get()); - if (memory_manager == nullptr) - { - _default_memory_manager = std::make_unique(); - _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);