[exo-tflite] Use throw instead of assert (#7006)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 29 Aug 2019 03:48:56 +0000 (12:48 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 29 Aug 2019 03:48:56 +0000 (12:48 +0900)
The current implementation of translateLocoTypeToTFLite may return an
invalid value if the code is built with release configuration.

This commit replaces assert with throw to prevent undefined behavior.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
compiler/exo-tflite/src/TypeInference.cpp

index ebfef90..b6e7667 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdex/Memory.h>
 
+#include <stdexcept>
 #include <type_traits>
 
 namespace
@@ -56,8 +57,10 @@ tflite::TensorType translateLocoTypeToTFLite(loco::DataType dtype)
       return tflite::TensorType_FLOAT32;
     //  case loco::DataType::FLOAT64: unsupported
     default:
-      assert(false && "unsupported data type");
+      break;
   }
+
+  throw std::invalid_argument{"dtype"};
 }
 
 } // namespace