From 66e1e4bb60b307eb1577b4181709d25390bfd00f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=94=D0=B8=D0=BB=D1=88=D0=BE=D0=B4=D0=B6=D0=BE=D0=BD=20?= =?utf8?q?=D0=A3=D0=BC=D1=80=D0=BE=D0=BD=D1=85=D0=BE=D0=BD=D0=BE=D0=B2?= =?utf8?q?=D0=B8=D1=87=20=D0=9F=D0=BE=D1=88=D1=88=D0=BE=D0=B5=D0=B2/AI=20T?= =?utf8?q?ools=20Lab=20/SRR/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 21 Dec 2018 04:06:19 +0300 Subject: [PATCH] [neurun]Merge 2 for-loops of PlanBuilder::finalize (#4118) Since these two loops are independent and loop over the same tensor_builders, better to merge them Signed-off-by: Poshshoev Dilshodzhon --- runtimes/neurun/src/compiler/PlanBuilder.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/runtimes/neurun/src/compiler/PlanBuilder.cc b/runtimes/neurun/src/compiler/PlanBuilder.cc index d934aa8..8ef3fed 100644 --- a/runtimes/neurun/src/compiler/PlanBuilder.cc +++ b/runtimes/neurun/src/compiler/PlanBuilder.cc @@ -27,16 +27,14 @@ void PlanBuilder::addStage(const Stage &stage) { _stages.emplace_back(stage); } void PlanBuilder::finalize(const backend::TensorBuilderSet &tensor_builders) { + auto &operands = _plan.operands(); + // Prepare tensors for (auto &tensor_builder : tensor_builders) { tensor_builder->prepare(); - } - // Wrap tensors as Object and store them to plan - auto &operands = _plan.operands(); - for (auto &tensor_builder : tensor_builders) - { + // Wrap tensors as Object and store them to plan tensor_builder->iterate([&](const model::operand::Index &index) { auto object = tensor_builder->wrapTensor(index); operands.set(index, object); -- 2.7.4