summaryrefslogtreecommitdiff
path: root/runtimes
diff options
context:
space:
mode:
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2019-04-18 13:39:15 +0900
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>2019-04-18 13:39:15 +0900
commit88ddcae5b63cbf5e09f78db653ef1abf37162d4d (patch)
treeffadf9f4aa5dcc8001ecee5f5364d251ffec2811 /runtimes
parent6d2b8ef1cfd59f5cbda435d3c1298fb1e138ab00 (diff)
downloadnnfw-88ddcae5b63cbf5e09f78db653ef1abf37162d4d.tar.gz
nnfw-88ddcae5b63cbf5e09f78db653ef1abf37162d4d.tar.bz2
nnfw-88ddcae5b63cbf5e09f78db653ef1abf37162d4d.zip
Prepare operand stack in interpreter (#5015)
Prepare operand stack in interpreter to save prepared operands to use Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
Diffstat (limited to 'runtimes')
-rw-r--r--runtimes/neurun/core/src/exec/interp/Interpreter.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/runtimes/neurun/core/src/exec/interp/Interpreter.cc b/runtimes/neurun/core/src/exec/interp/Interpreter.cc
index 5504e957d..536b19cf0 100644
--- a/runtimes/neurun/core/src/exec/interp/Interpreter.cc
+++ b/runtimes/neurun/core/src/exec/interp/Interpreter.cc
@@ -16,6 +16,9 @@
#include "Interpreter.h"
+#include <stack>
+
+#include "model/operand/IndexMap.h"
#include "util/logging.h"
namespace neurun
@@ -29,6 +32,32 @@ void Interpreter::run()
{
VERBOSE(INTERPRETER) << "Interpreter is invoked " << std::endl;
+ // operand_stack: save operands prepared to use
+ std::stack<model::operand::Index> operand_stack;
+
+ // Note: We should push input first, then constant.
+ // We use use-def for find operators ready to execution,
+ // but Use-Def cannot handle parameters (maybe constant, but not always)
+ // Note: If all model inputs are constant, it may not work (depend on tensors' order).
+ // But that scenario may not exist
+ for (auto ind : _env->model().inputs)
+ {
+ VERBOSE(INTERPRETER) << "Input: Push to operand stack " << ind.value() << std::endl;
+
+ operand_stack.push(ind);
+ }
+
+ _env->model().operands.iterate(
+ [&](const model::operand::Index &ind, const model::operand::Object &obj) {
+ if (obj.hasData())
+ {
+ VERBOSE(INTERPRETER) << "Constant: Push to operand stack " << ind.value() << std::endl;
+
+ operand_stack.push(ind);
+ }
+ });
+
+ // Execution
throw std::runtime_error("NYI: interpreter run");
}