Use ExternalData for zero length value (#2618)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 6 Sep 2018 04:17:09 +0000 (13:17 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Thu, 6 Sep 2018 04:17:09 +0000 (13:17 +0900)
Use ExternalData for object with no value (nullptr buffer from setOperandValue)

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/pure_arm_compute/src/model.cc

index a92164a..e549468 100644 (file)
@@ -112,9 +112,16 @@ int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel *model, int32_t in
   const internal::tflite::operand::Index ind{index};
   auto &obj = model->deref().operands().at(ind);
 
-  using internal::tflite::operand::CachedData;
-
-  obj.data<CachedData>(reinterpret_cast<const uint8_t *>(buffer), length);
+  if (buffer == nullptr)
+  {
+    using internal::tflite::operand::ExternalData;
+    obj.data<ExternalData>(reinterpret_cast<const uint8_t *>(buffer), length);
+  }
+  else
+  {
+    using internal::tflite::operand::CachedData;
+    obj.data<CachedData>(reinterpret_cast<const uint8_t *>(buffer), length);
+  }
 
   return ANEURALNETWORKS_NO_ERROR;
 }