From 8ccf064eaa0b0dae0178772b9630e2da7065afb2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 25 Mar 2019 19:19:15 +0900 Subject: [PATCH] [neurun] Extract OperandContext from Plan (#4834) Extract OperandContext from Plan so OperandContext can be merged in ExecutorBase. (Both Executor and DataflowExecutor contains OperandContext so we can promote it to ExecutorBase, later.) Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/src/compiler/Compiler.cc | 4 ++-- runtimes/neurun/core/src/compiler/Plan.h | 7 ++----- runtimes/neurun/core/src/exec/Executor.cc | 4 ++-- runtimes/neurun/core/src/exec/Executor.h | 5 ++++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/runtimes/neurun/core/src/compiler/Compiler.cc b/runtimes/neurun/core/src/compiler/Compiler.cc index 73f070f..a7a9d58 100644 --- a/runtimes/neurun/core/src/compiler/Compiler.cc +++ b/runtimes/neurun/core/src/compiler/Compiler.cc @@ -140,9 +140,9 @@ std::shared_ptr Compiler::createLinearExecutor(graph::Graph &mo ConstantInitializer{model, *operand_context, *linear->getLowerInfo()}(); - auto plan = std::make_shared(operand_context, operation_sequence); + auto plan = std::make_shared(operation_sequence); return std::make_shared(model.shareModel(), linear->releaseSubgraphSet(), - linear->releaseLowerInfo(), plan); + linear->releaseLowerInfo(), operand_context, plan); } std::shared_ptr Compiler::createDataflowExecutor(graph::Graph &model) diff --git a/runtimes/neurun/core/src/compiler/Plan.h b/runtimes/neurun/core/src/compiler/Plan.h index 4c5da26..e0d1044 100644 --- a/runtimes/neurun/core/src/compiler/Plan.h +++ b/runtimes/neurun/core/src/compiler/Plan.h @@ -39,20 +39,17 @@ public: * @param[in] ops Compiled operation sequence * @param[in] compiled @c true if model is compiled successfully, otherwise @c false */ - Plan(std::shared_ptr &operands, std::shared_ptr &ops, - bool compiled = true) - : _operands{operands}, _ops{ops}, _compiled{compiled} + Plan(std::shared_ptr &ops, bool compiled = true) + : _ops{ops}, _compiled{compiled} { // DO NOTHING } public: - const OperandContext &operands(void) const { return *_operands; } const operation::Sequence &operations(void) const { return *_ops; } bool isCompiled(void) const { return _compiled; } private: - std::shared_ptr _operands{nullptr}; std::shared_ptr _ops{nullptr}; bool _compiled{false}; }; diff --git a/runtimes/neurun/core/src/exec/Executor.cc b/runtimes/neurun/core/src/exec/Executor.cc index 8e6f319..3c129f8 100644 --- a/runtimes/neurun/core/src/exec/Executor.cc +++ b/runtimes/neurun/core/src/exec/Executor.cc @@ -45,7 +45,7 @@ void Executor::execute() continue; } - auto object = _plan->operands().at(index); + auto object = _operand_context->at(index); object->access(setter); } @@ -65,7 +65,7 @@ void Executor::execute() neurun::model::operand::IO::Index output_index{n}; ::neurun::model::operand::Index index{_model->outputs.at(output_index)}; - auto object = _plan->operands().at(index); + auto object = _operand_context->at(index); object->access(getter); } diff --git a/runtimes/neurun/core/src/exec/Executor.h b/runtimes/neurun/core/src/exec/Executor.h index b20d449..d9cf1f2 100644 --- a/runtimes/neurun/core/src/exec/Executor.h +++ b/runtimes/neurun/core/src/exec/Executor.h @@ -43,8 +43,10 @@ public: Executor(const std::shared_ptr &model, std::unique_ptr>> subg_set, std::unique_ptr lower_info, + const std::shared_ptr &operand_context, const std::shared_ptr &plan) - : ExecutorBase{model, std::move(subg_set), std::move(lower_info)}, _plan{plan} + : ExecutorBase{model, std::move(subg_set), std::move(lower_info)}, + _operand_context{operand_context}, _plan{plan} { } @@ -52,6 +54,7 @@ public: virtual void execute(void) override; private: + std::shared_ptr _operand_context; std::shared_ptr _plan; }; -- 2.7.4