[Tools] Check tflite file correctness (#2767)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 19 Sep 2018 04:08:49 +0000 (13:08 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 19 Sep 2018 04:08:49 +0000 (13:08 +0900)
- Check tflite file correctness to parse operator option table (option table type defined but undefined value)
- Print and exit if operator selector cannot support

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
tools/tflitefile_tool/operator_wrapping.py
tools/tflitefile_tool/select_operator.py

index 1b7f55a..dcd9735 100755 (executable)
@@ -64,6 +64,11 @@ class OptionLoader:
 
     @staticmethod
     def GetBuiltinOptions(options_type, options_table):
+        if options_table == None:
+            print(
+                "Bad flatbuffer file: undefined builtin option table with defined option type"
+            )
+            exit(1)
         options = OptionLoader.builtinOptionGen[options_type]()
         options.Init(options_table.Bytes, options_table.Pos)
         return options
index 55ca1ac..87e2813 100755 (executable)
@@ -431,7 +431,8 @@ def GenerateBuiltinOption(new_builder, selected_builtin_option, builtin_option_t
         return tflite.GatherOptions.GatherOptionsEnd(new_builder)
 
     # Cannot handle builtin option type yet
-    return 0
+    print("Cannot handle this option yet")
+    exit(1)
 
 
 def GenerateOperator(new_builder, selected_operator, used_tensors_dic,