From 089285134303dd55d8c8117dfdb32a863c58273e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Mon, 15 Oct 2018 13:28:48 +0900 Subject: [PATCH] Revert "[neurun] Only one item for codegen operand Context (#3043)" (#3127) This reverts commit f607de26dcf88a20de5e1d303390f9253cb27c34. There is no easy way to fix #3126, so reverting the problematic change. However still, we need to fix it. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/codegen/PlanBuilder.cc | 7 +++++-- runtimes/neurun/src/codegen/operand/Context.cc | 6 +----- runtimes/neurun/src/codegen/operand/Context.h | 7 ++++--- runtimes/neurun/src/frontend/execution.cc | 14 ++++++++++---- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/runtimes/neurun/src/codegen/PlanBuilder.cc b/runtimes/neurun/src/codegen/PlanBuilder.cc index 575cf78..dd5e5d6 100644 --- a/runtimes/neurun/src/codegen/PlanBuilder.cc +++ b/runtimes/neurun/src/codegen/PlanBuilder.cc @@ -75,9 +75,12 @@ void PlanBuilder::finalize(const backend::TensorBuilderSet &tensor_builders) for (auto it = _initializer_ctx.begin(); it != _initializer_ctx.end(); ++it) { const ::neurun::graph::operand::Index operand_index{it->first}; - auto object = _plan.operands().at(operand_index); + auto objects = _plan.operands().at(operand_index); - object->access(it->second); + for (auto object : objects) + { + object->access(it->second); + } } } diff --git a/runtimes/neurun/src/codegen/operand/Context.cc b/runtimes/neurun/src/codegen/operand/Context.cc index 76ba59f..7e5cdec 100644 --- a/runtimes/neurun/src/codegen/operand/Context.cc +++ b/runtimes/neurun/src/codegen/operand/Context.cc @@ -16,8 +16,6 @@ #include "Context.h" -#include - namespace neurun { namespace codegen @@ -28,9 +26,7 @@ namespace operand Context &Context::set(const graph::operand::Index &id, const std::shared_ptr &object) { - // Only one object for an id - assert(_objects.find(id.value()) == _objects.end()); - _objects[id.value()] = object; + _objects[id.value()].emplace_back(object); return (*this); } diff --git a/runtimes/neurun/src/codegen/operand/Context.h b/runtimes/neurun/src/codegen/operand/Context.h index b1000a8..940d690 100644 --- a/runtimes/neurun/src/codegen/operand/Context.h +++ b/runtimes/neurun/src/codegen/operand/Context.h @@ -42,18 +42,19 @@ public: } public: - std::shared_ptr at(const graph::operand::Index &ind) const + const std::vector> & + at(const graph::operand::Index &ind) const { return _objects.at(ind.asInt()); } - std::shared_ptr &at(const graph::operand::Index &ind) + std::vector> &at(const graph::operand::Index &ind) { return _objects.at(ind.asInt()); } private: - std::map> _objects; + std::map>> _objects; }; } // namespace operand diff --git a/runtimes/neurun/src/frontend/execution.cc b/runtimes/neurun/src/frontend/execution.cc index 8a3c60c..30c9451 100644 --- a/runtimes/neurun/src/frontend/execution.cc +++ b/runtimes/neurun/src/frontend/execution.cc @@ -440,9 +440,12 @@ int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution *execution, neurun::graph::operand::IO::Index input_index{n}; ::neurun::graph::operand::Index index{model.getInputs().at(input_index)}; - auto object = plan.operands().at(index); + auto objects = plan.operands().at(index); - object->access(setter); + for (auto object : objects) + { + object->access(setter); + } } const auto &operations = execution->plan().operations(); @@ -460,9 +463,12 @@ int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution *execution, neurun::graph::operand::IO::Index output_index{n}; ::neurun::graph::operand::Index index{model.getOutputs().at(output_index)}; - auto object = plan.operands().at(index); + auto objects = plan.operands().at(index); - object->access(getter); + for (auto object : objects) + { + object->access(getter); + } } return ANEURALNETWORKS_NO_ERROR; -- 2.7.4