This is an automated email from the ASF dual-hosted git repository.

leandron 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 d60fb7295e [TFLite][Frontend] Support quantized NOT_EQUAL (#15769)
d60fb7295e is described below

commit d60fb7295edd4b360996ce2366c3447563f475d9
Author: Tlopex <68688494+tlo...@users.noreply.github.com>
AuthorDate: Mon Sep 18 16:51:37 2023 +0800

    [TFLite][Frontend] Support quantized NOT_EQUAL (#15769)
    
    * make not_equal quantized
    
    * add tests to quantized not_equal
    
    * add quantized not_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 28389d9a22..6728263c7f 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -1498,11 +1498,7 @@ class OperatorConverter(object):
 
     def convert_not_equal(self, op):
         """Convert TFLite NOT_EQUAL"""
-        if self.is_quantized(op):
-            raise tvm.error.OpNotImplemented(
-                "TFlite quantized NOT_EQUAL operator is not supported yet."
-            )
-        return self._convert_elemwise(_op.not_equal, op)
+        return self._convert_elemwise(_op.not_equal, op, 
self.is_quantized(op), comparison_op=True)
 
     def _convert_logical_binary(self, relay_op, op):
         """Generic method to convert logical binary ops"""
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index 9917659945..ab89de6301 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -2735,9 +2735,17 @@ def _test_equal(data, fused_activation_function=None, 
quantized=False, qnn_op=No
 # ---------
 
 
-def _test_not_equal(data):
+def _test_not_equal(data, fused_activation_function=None, quantized=False, 
qnn_op=None):
     """One iteration of not_equal"""
-    return _test_elemwise(math_ops.not_equal, data)
+    return _test_elemwise(
+        math_ops.not_equal,
+        data,
+        fused_activation_function,
+        quantized,
+        qnn_op,
+        same_qnn_params=True,
+        comparison_op=True,
+    )
 
 
 #######################################################################
@@ -2841,6 +2849,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
         _test_floor_divide: (-150, 150),
         _test_less: (-150, 150),
         _test_floor_mod: (-150, 150),
+        _test_not_equal: (-150, 150),
     }
 
     return qnn_out_range[qnn_op]
@@ -2882,6 +2891,7 @@ def test_all_elemwise():
     _test_forward_elemwise(_test_equal)
     _test_forward_elemwise_quantized(_test_equal)
     _test_forward_elemwise(_test_not_equal)
+    _test_forward_elemwise_quantized(_test_not_equal)
     if package_version.parse(tf.VERSION) >= package_version.parse("1.14.0"):
         _test_forward_elemwise(_test_floor_divide)
         _test_forward_elemwise_quantized(_test_floor_divide)

Reply via email to