[tfltool] Enable select operator for RNN op (#3825)
authorDevansh Bansal/SNAP /SRI-Bangalore/Engineer/삼성전자 <b.devansh@samsung.com>
Mon, 3 Dec 2018 11:27:31 +0000 (16:57 +0530)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 3 Dec 2018 11:27:31 +0000 (20:27 +0900)
This patch enables RNN in tflitetool in select_operator.py

Signed-off-by: b.devansh <b.devansh@samsung.com>
tools/tflitefile_tool/select_operator.py

index 1233045..12deac1 100755 (executable)
@@ -293,7 +293,18 @@ def GenerateBuiltinOption(new_builder, selected_builtin_option, builtin_option_t
         return tflite.Pool2DOptions.Pool2DOptionsEnd(new_builder)
 
     # SVDFOptions: not supported
-    # RNNOptions: not supported
+
+    # RNNOptions
+    import tflite.RNNOptions
+    if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().RNNOptions:
+
+        add_option = tflite.RNNOptions.RNNOptions()
+        add_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
+
+        tflite.RNNOptions.RNNOptionsStart(new_builder)
+        tflite.RNNOptions.RNNOptionsAddFusedActivationFunction(
+            new_builder, add_option.FusedActivationFunction())
+        return tflite.RNNOptions.RNNOptionsEnd(new_builder)
 
     # FullyConnectedOptions
     import tflite.FullyConnectedOptions