From a335496ab971bce7f616c7678a2b1929c93afc1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 28 Mar 2019 16:56:37 +0900 Subject: [PATCH] [Interpreter] Allocate and assign constant tensor (#4888) Allocate tensor for constant operand Assign constant tensor to exec-env Signed-off-by: Hyeongseok Oh --- runtimes/neurun/core/src/exec/interp/ExecManager.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/runtimes/neurun/core/src/exec/interp/ExecManager.cc b/runtimes/neurun/core/src/exec/interp/ExecManager.cc index a8e0785..40dfab7 100644 --- a/runtimes/neurun/core/src/exec/interp/ExecManager.cc +++ b/runtimes/neurun/core/src/exec/interp/ExecManager.cc @@ -84,6 +84,7 @@ void ExecManager::execute(void) { if (_tensor_map.find(index) != _tensor_map.end()) { + VERBOSE(INTERPRETER) << "Assign input tensor. operand index:" << index.value() << std::endl; interp_env->assignTensor(index, _tensor_map.at(index)); } } @@ -93,11 +94,26 @@ void ExecManager::execute(void) { if (_tensor_map.find(index) != _tensor_map.end()) { + VERBOSE(INTERPRETER) << "Assign output tensor. operand index: " << index.value() << std::endl; interp_env->assignTensor(index, _tensor_map.at(index)); } } - // TODO Allocate constant tensor + // Allocate constant tensor + _model->operands.iterate([&](const model::operand::Index &ind, + const model::operand::Object &obj) { + if (obj.usage() == model::operand::Usage::CONSTANT) + { + VERBOSE(INTERPRETER) << "Allocate and assign constant tensor. operand index:" << ind.value() + << std::endl; + + auto const_tensor = std::make_shared(TensorInfo(obj.info())); + interp_env->assignTensor(ind, const_tensor); + // Assume that interpreter's tensor layout is same with model (NHWC) + const_tensor->setBuffer(obj.data().base()); + } + }); + // TODO Interpreter execution throw std::runtime_error{"NYI: ExecManager execute"}; -- 2.7.4