[Pure CL Runtime] Handle shape with rank one on setInput/Output (#1449)
author서상민/동작제어Lab(SR)/Staff Engineer/삼성전자 <sangmin7.seo@samsung.com>
Thu, 31 May 2018 02:43:37 +0000 (11:43 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 31 May 2018 02:43:37 +0000 (11:43 +0900)
This patch revises ANeuralNetworksExecution_setInput/Output to handle
the case of rank one.

Signed-off-by: Sangmin Seo <sangmin7.seo@samsung.com>
runtimes/pure_arm_compute/src/execution.cc

index 0214b6a..0884f96 100644 (file)
@@ -161,7 +161,13 @@ int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32
   // TODO Remove this assumption
   const auto operand_index = execution->plan().model().inputs.at(index);
 
-  if (operands.at(operand_index).shape().rank() == 2)
+  if (operands.at(operand_index).shape().rank() == 1)
+  {
+    const auto len = operands.at(operand_index).shape().dim(0);
+
+    execution->source<VectorSource>(index, len, reinterpret_cast<const uint8_t *>(buffer), length);
+  }
+  else if (operands.at(operand_index).shape().rank() == 2)
   {
     assert(operands.at(operand_index).shape().dim(0) == 1);
 
@@ -194,8 +200,14 @@ int ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution *execution, int3
 
   const auto operand_index = execution->plan().model().outputs.at(index);
 
-  if ((operands.at(operand_index).shape().rank() == 2) &&
-      (operands.at(operand_index).shape().dim(0) == 1))
+  if (operands.at(operand_index).shape().rank() == 1)
+  {
+    const auto len = operands.at(operand_index).shape().dim(0);
+
+    execution->sink<VectorSink>(index, len, reinterpret_cast<uint8_t *>(buffer), length);
+  }
+  else if ((operands.at(operand_index).shape().rank() == 2) &&
+           (operands.at(operand_index).shape().dim(0) == 1))
   {
     const auto len = operands.at(operand_index).shape().dim(1);