[Loader] Fix quantizaion info loading (#5450)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 19 Jun 2019 07:49:03 +0000 (16:49 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 19 Jun 2019 07:49:03 +0000 (16:49 +0900)
Check nullptr to get quantizaion info

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
contrib/tflite_loader/loader.cc

index 4096d04..d7ed649 100644 (file)
@@ -85,14 +85,17 @@ void Loader::loadOperand(const tflite::Tensor *tensor)
   // auto name = tensor->name();
   // Quantization
   auto quantization = tensor->quantization();
-  auto scale = quantization->scale();
-  auto zero_point = quantization->zero_point();
-  if (scale != NULL || zero_point != NULL)
-    throw std::runtime_error("Quantization is not supported!");
-
-  auto details = quantization->details_as_CustomQuantization();
-  if (details != NULL)
-    throw std::runtime_error("Custom Quantization is not supported");
+  if (quantization != nullptr)
+  {
+    auto scale = quantization->scale();
+    auto zero_point = quantization->zero_point();
+    if (scale != nullptr || zero_point != nullptr)
+      throw std::runtime_error("Quantization is not supported!");
+
+    auto details = quantization->details_as_CustomQuantization();
+    if (details != nullptr)
+      throw std::runtime_error("Custom Quantization is not supported");
+  }
   // Variablie
   if (tensor->is_variable())
     throw std::runtime_error("Variable tensor not supported!");