[tflitefile_tool] Support leaky_relu in select_operator.py (#3983)
authorHyeongseok Oh <hseok82.oh@samsung.com>
Wed, 26 Aug 2020 03:18:06 +0000 (12:18 +0900)
committerGitHub <noreply@github.com>
Wed, 26 Aug 2020 03:18:06 +0000 (12:18 +0900)
select_operator.py can handle LeakyReluOption for leaky_relu operation

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

index dcafd75..863edea 100755 (executable)
@@ -875,7 +875,18 @@ def GenerateBuiltinOption(new_builder, selected_builtin_option, builtin_option_t
     # FloorModOptions: not supported
     # RangeOptions: not supported
     # ResizeNearestNeighborOptions: not supported
-    # LeakyReluOptions: not supported
+
+    # LeakyReluOptions
+    import tflite.LeakyReluOptions
+    if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().LeakyReluOptions:
+
+        leaky_relu_option = tflite.LeakyReluOptions.LeakyReluOptions()
+        leaky_relu_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
+
+        tflite.LeakyReluOptions.LeakyReluOptionsStart(new_builder)
+        tflite.LeakyReluOptions.LeakyReluOptionsAddAlpha(new_builder,
+                                                         leaky_relu_option.Alpha())
+        return tflite.LeakyReluOptions.LeakyReluOptionsEnd(new_builder)
 
     # SquaredDifferenceOptions
     import tflite.SquaredDifferenceOptions