Handle optional input & output on frontend (#3763)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 3 Dec 2018 10:43:43 +0000 (19:43 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 3 Dec 2018 10:43:43 +0000 (19:43 +0900)
- Throw exception when optional input is set because we cannot support this yet
- Return with do nothing for optional output

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/frontend/execution.cc

index 4cc7bb9..f35db59 100644 (file)
@@ -180,6 +180,12 @@ int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32
     return ANEURALNETWORKS_UNEXPECTED_NULL;
   }
 
+  // TODO Handle optional input
+  if (buffer == nullptr)
+  {
+    throw std::runtime_error("Not supported optional input, yet");
+  }
+
   const auto &operands = execution->plan().model().operands();
 
   // TODO Check type conflicts
@@ -208,6 +214,12 @@ int ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution *execution, int3
     return ANEURALNETWORKS_UNEXPECTED_NULL;
   }
 
+  // Handle optional output
+  if (buffer == nullptr)
+  {
+    return ANEURALNETWORKS_NO_ERROR;
+  }
+
   const auto &operands = execution->plan().model().operands();
 
   // TODO Check type conflicts