summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2019-04-17 00:14:19 (GMT)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>2019-04-17 00:14:19 (GMT)
commit23be4330f239bca3b56670b4cfc3f029acb90a1a (patch)
tree367f06009e656d1e331313b2edfbdd18ecd43a29
parent98728aa36574fa5ec657159420eaed3a3498b7cd (diff)
downloadnnfw-23be4330f239bca3b56670b4cfc3f029acb90a1a.zip
nnfw-23be4330f239bca3b56670b4cfc3f029acb90a1a.tar.gz
nnfw-23be4330f239bca3b56670b4cfc3f029acb90a1a.tar.bz2
Introduce interpreter class (#5006)
* Introduce interpreter class Introduce interpreter class: run on assigned ExecEnv Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com> * Fix define for header
-rw-r--r--runtimes/neurun/core/src/exec/interp/ExecManager.cc15
-rw-r--r--runtimes/neurun/core/src/exec/interp/Interpreter.cc37
-rw-r--r--runtimes/neurun/core/src/exec/interp/Interpreter.h67
3 files changed, 117 insertions, 2 deletions
diff --git a/runtimes/neurun/core/src/exec/interp/ExecManager.cc b/runtimes/neurun/core/src/exec/interp/ExecManager.cc
index 0fdf1b7..e3d4c31 100644
--- a/runtimes/neurun/core/src/exec/interp/ExecManager.cc
+++ b/runtimes/neurun/core/src/exec/interp/ExecManager.cc
@@ -16,6 +16,8 @@
#include "ExecManager.h"
#include "ExecEnv.h"
+#include "Interpreter.h"
+
#include "util/logging.h"
#include <cpp14/memory.h>
@@ -146,9 +148,18 @@ void ExecManager::execute(void)
}
});
- // TODO Interpreter execution
+ /*****************************************************************************
+ * Invoke interpreter
+ ****************************************************************************/
+
+ Interpreter interp(std::move(interp_env));
+ interp.run();
+
+ /*****************************************************************************
+ * Invoked interpreter run is finished
+ ****************************************************************************/
- throw std::runtime_error{"NYI: ExecManager execute"};
+ throw std::runtime_error{"NYI: ExecManager handle model output"};
}
} // namespace interp
diff --git a/runtimes/neurun/core/src/exec/interp/Interpreter.cc b/runtimes/neurun/core/src/exec/interp/Interpreter.cc
new file mode 100644
index 0000000..5504e95
--- /dev/null
+++ b/runtimes/neurun/core/src/exec/interp/Interpreter.cc
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Interpreter.h"
+
+#include "util/logging.h"
+
+namespace neurun
+{
+namespace exec
+{
+namespace interp
+{
+
+void Interpreter::run()
+{
+ VERBOSE(INTERPRETER) << "Interpreter is invoked " << std::endl;
+
+ throw std::runtime_error("NYI: interpreter run");
+}
+
+} // namespace interp
+} // namespace exec
+} // namespace neurun
diff --git a/runtimes/neurun/core/src/exec/interp/Interpreter.h b/runtimes/neurun/core/src/exec/interp/Interpreter.h
new file mode 100644
index 0000000..1b73592
--- /dev/null
+++ b/runtimes/neurun/core/src/exec/interp/Interpreter.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file Interpreter.h
+ * @brief This file contains Interpreter class for interpretation
+ */
+#ifndef __NEURUN_EXEC_INTERP_INTERPRETER_H__
+#define __NEURUN_EXEC_INTERP_INTERPRETER_H__
+
+#include "ExecEnv.h"
+
+namespace neurun
+{
+namespace exec
+{
+namespace interp
+{
+
+/**
+ * @brief Class for interpretation
+ */
+class Interpreter
+{
+
+public:
+ /**
+ * @brief Construct a new Interpreter object (deleted)
+ */
+ Interpreter() = delete;
+ /**
+ * @brief Construct a new Interpreter object
+ * @param[in] env Execution environment variable for interpreter object
+ */
+ Interpreter(std::unique_ptr<ExecEnv> env) : _env{std::move(env)}
+ {
+ // DO NOTHING
+ }
+
+public:
+ /**
+ * @brief Run interpreter until there is no operation to execute
+ */
+ void run();
+
+private:
+ std::unique_ptr<ExecEnv> _env;
+};
+
+} // namespace interp
+} // namespace exec
+} // namespace neurun
+
+#endif // __NEURUN_EXEC_INTERP_INTERPRETER_H__