This is an automated email from the ASF dual-hosted git repository.
syfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 61bed643aa [TFLite][Frontend] Support quantized LESS_EQUAL (#15790)
61bed643aa is described below
commit 61bed643aab793aeefa4e411eb67f67e12226670
Author: Tlopex <[email protected]>
AuthorDate: Fri Sep 22 12:27:31 2023 +0800
[TFLite][Frontend] Support quantized LESS_EQUAL (#15790)
* Update tflite.py
* add tests to quantized less_equal
---
python/tvm/relay/frontend/tflite.py | 6 +-----
tests/python/frontend/tflite/test_forward.py | 14 ++++++++++++--
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/python/tvm/relay/frontend/tflite.py
b/python/tvm/relay/frontend/tflite.py
index 9e72049ecd..4eaa8280c3 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -1484,11 +1484,7 @@ class OperatorConverter(object):
def convert_less_equal(self, op):
"""Convert TFLite LESS_EQUAL"""
- if self.is_quantized(op):
- raise tvm.error.OpNotImplemented(
- "TFlite quantized LESS_EQUAL operator is not supported yet."
- )
- return self._convert_elemwise(_op.less_equal, op)
+ return self._convert_elemwise(_op.less_equal, op,
self.is_quantized(op), comparison_op=True)
def convert_equal(self, op):
"""Convert TFLite EQUAL"""
diff --git a/tests/python/frontend/tflite/test_forward.py
b/tests/python/frontend/tflite/test_forward.py
index b981145c1c..f1e2e28f08 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -2715,9 +2715,17 @@ def _test_less(data, fused_activation_function=None,
quantized=False, qnn_op=Non
# ----------
-def _test_less_equal(data):
+def _test_less_equal(data, fused_activation_function=None, quantized=False,
qnn_op=None):
"""One iteration of less_equal"""
- return _test_elemwise(math_ops.less_equal, data)
+ return _test_elemwise(
+ math_ops.less_equal,
+ data,
+ fused_activation_function,
+ quantized,
+ qnn_op,
+ same_qnn_params=True,
+ comparison_op=True,
+ )
#######################################################################
@@ -2858,6 +2866,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
_test_less: (-150, 150),
_test_floor_mod: (-150, 150),
_test_not_equal: (-150, 150),
+ _test_less_equal: (-150, 150),
_test_greater_equal: (-150, 150),
}
@@ -2898,6 +2907,7 @@ def test_all_elemwise():
_test_forward_elemwise(_test_less)
_test_forward_elemwise_quantized(_test_less)
_test_forward_elemwise(_test_less_equal)
+ _test_forward_elemwise_quantized(_test_less_equal)
_test_forward_elemwise(_test_equal)
_test_forward_elemwise_quantized(_test_equal)
_test_forward_elemwise(_test_not_equal)