Fix non-string passed to CreateString issue in tfltool (#3645)
author윤지영/동작제어Lab(SR)/Engineer/삼성전자 <jy910.yun@samsung.com>
Tue, 20 Nov 2018 05:13:15 +0000 (14:13 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 20 Nov 2018 05:13:15 +0000 (14:13 +0900)
If the operator_codes is empty, select_operator.py tool occurs an error.
This patch is fixed the issue.

Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
tools/tflitefile_tool/select_operator.py

index 27030e9..1233045 100755 (executable)
@@ -76,8 +76,8 @@ def GenerateOperatorCodes(new_builder, sample_model, used_operators_dic):
         if operator_code_idx in used_operators_dic:
             operator_code = sample_model.OperatorCodes(operator_code_idx)
             operator_code_string = operator_code.CustomCode()
-            if (operator_code_string !=
-                    "") and (not operator_code_string in new_operator_code_string_list):
+            if operator_code_string and (operator_code_string != "") and (
+                    not operator_code_string in new_operator_code_string_list):
                 new_operator_code_string_list[
                     operator_code_string] = new_builder.CreateString(operator_code_string)
 
@@ -802,7 +802,7 @@ def GenerateSubgraph(new_builder, selected_subgraph, opcode_list, new_input_tens
     # Name
     subgraph_name = selected_subgraph.Name()
     have_name = False
-    if subgraph_name != "":
+    if subgraph_name and subgraph_name != "":
         have_name = True
         new_subgraph_name = new_builder.CreateString(subgraph_name)