Implement nnfw_run,set_input,set_output (#5605)
author이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 10 Jul 2019 02:17:18 +0000 (11:17 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 10 Jul 2019 02:17:18 +0000 (11:17 +0900)
- Implement nnfw_run, nnfw_set_input, nnfw_set_output

Signed-off-by: Chunseok Lee <chunseok.lee@samsung.com>
runtimes/neurun/frontend/api/wrapper/nnfw_api.cc

index d7d6dad..be4266a 100644 (file)
@@ -85,18 +85,43 @@ NNFW_STATUS nnfw_session::prepare()
 
 NNFW_STATUS nnfw_session::run()
 {
-  // TODO : add run routine
+  try
+  {
+    _executor->execute();
+  }
+  catch (...)
+  {
+    std::cerr << "Error during nnfw_session::run" << std::endl;
+    return NNFW_STATUS_ERROR;
+  }
+
   return NNFW_STATUS_NO_ERROR;
 }
 
 NNFW_STATUS nnfw_session::set_input(int index, NNFW_TYPE type, const void *buffer, size_t length)
 {
-  // TODO : add set input routine
+  try
+  {
+    _executor->setInput(neurun::model::IOIndex(index), buffer, length);
+  }
+  catch (...)
+  {
+    std::cerr << "Error during nnfw_session::set_input" << std::endl;
+    return NNFW_STATUS_ERROR;
+  }
   return NNFW_STATUS_NO_ERROR;
 }
 
 NNFW_STATUS nnfw_session::set_output(int index, NNFW_TYPE type, void *buffer, size_t length)
 {
-  // TODO : add set output routine
+  try
+  {
+    _executor->setOutput(neurun::model::IOIndex(index), buffer, length);
+  }
+  catch (...)
+  {
+    std::cerr << "Error during nnfw_session::set_output" << std::endl;
+    return NNFW_STATUS_ERROR;
+  }
   return NNFW_STATUS_NO_ERROR;
 }