From 61c3de3da4c282b5c4ebaaebfda74ec18cbc0340 Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:57:15 +0800 Subject: [PATCH 1/8] add quantized pow --- python/tvm/relay/frontend/tflite.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/tvm/relay/frontend/tflite.py b/python/tvm/relay/frontend/tflite.py index 6728263c7f0e..796e1c495b27 100644 --- a/python/tvm/relay/frontend/tflite.py +++ b/python/tvm/relay/frontend/tflite.py @@ -1434,8 +1434,6 @@ def convert_div(self, op): def convert_pow(self, op): """Convert TFLite POW""" # Check if the input tensor is quantized, call QNN op - if self.is_quantized(op): - raise tvm.error.OpNotImplemented("TFlite quantized POW operator is not supported yet.") return self._convert_elemwise(_op.power, op) def convert_maximum(self, op): From 0bd3e2d684343965d5f4c656f20ea6fe972416ab Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:07:35 +0800 Subject: [PATCH 2/8] add tests for quantized pow --- tests/python/frontend/tflite/test_forward.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index ab89de6301b2..fae1fb78f8f4 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2627,9 +2627,16 @@ def _test_div(data, fused_activation_function=None, quantized=False, qnn_op=None # ----- -def _test_pow(data): +def _test_pow(data, fused_activation_function=None, quantized=False, qnn_op=None): """One iteration of power""" - return _test_elemwise(math_ops.pow, data) + return _test_elemwise( + math_ops.pow, + data, + fused_activation_function, + quantized, + qnn_op, + same_qnn_params=True, + ) ####################################################################### @@ -2850,6 +2857,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), + _test_pow: (-150, 150), } return qnn_out_range[qnn_op] @@ -2876,6 +2884,7 @@ def test_all_elemwise(): _test_forward_elemwise(partial(_test_div, fused_activation_function="RELU6")) _test_forward_elemwise_quantized(_test_div) _test_forward_elemwise(_test_pow) + _test_forward_elemwise_quantized(_test_pow) _test_forward_elemwise(_test_maximum) _test_forward_elemwise_quantized(_test_maximum) _test_forward_elemwise(_test_minimum) From f605a93f49563a94dc140e60a2eace84a3ece39d Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Thu, 21 Sep 2023 20:50:37 +0800 Subject: [PATCH 3/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index 85d82a9deca0..6b6a731ec4b4 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2865,7 +2865,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (-150, 150), + _test_pow: (-5e3, 5e3), _test_greater_equal: (-150, 150), } From a8339823bb80690a705c6dd1e5ca5d891b3cde5a Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Sat, 30 Sep 2023 01:52:43 +0800 Subject: [PATCH 4/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index a925f6e77e6b..72e2145582a0 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2873,7 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (-8, 8), + _test_pow: (0, 20), _test_less_equal: (-150, 150), _test_greater_equal: (-150, 150), } From 5a4d17b3fccd745d735948ca9d2066aefc344eb1 Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:30:46 +0800 Subject: [PATCH 5/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index 72e2145582a0..1cd8c9f01e99 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2873,7 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (0, 20), + _test_pow: (0, 26), _test_less_equal: (-150, 150), _test_greater_equal: (-150, 150), } From e813a6ecafeedbc99f5e20c175710663f07c79ee Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Sat, 30 Sep 2023 16:51:54 +0800 Subject: [PATCH 6/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index 1cd8c9f01e99..ef2d91452068 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2873,7 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (0, 26), + _test_pow: (0, 10), _test_less_equal: (-150, 150), _test_greater_equal: (-150, 150), } From 7dbd473360472ed90a9bba926979b43d07b631c0 Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Sat, 30 Sep 2023 20:09:08 +0800 Subject: [PATCH 7/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index ef2d91452068..c0bb36f6401a 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2873,7 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (0, 10), + _test_pow: (0, 3e38), _test_less_equal: (-150, 150), _test_greater_equal: (-150, 150), } From 489f566708fcf4111f872c46fa4f0d508868e71b Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Sat, 30 Sep 2023 23:36:58 +0800 Subject: [PATCH 8/8] Update test_forward.py --- tests/python/frontend/tflite/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index c0bb36f6401a..d9a53fd51719 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2873,7 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op): _test_less: (-150, 150), _test_floor_mod: (-150, 150), _test_not_equal: (-150, 150), - _test_pow: (0, 3e38), + _test_pow: (0, 3), _test_less_equal: (-150, 150), _test_greater_equal: (-150, 150), }