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

lukhut 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 e3055c1970 [TFLite][Frontend] Support quantized floor_div (#15724)
e3055c1970 is described below

commit e3055c19702ff58819fa064565a6e1aa1443818e
Author: Anatol Liu <[email protected]>
AuthorDate: Tue Sep 12 06:50:06 2023 -0400

    [TFLite][Frontend] Support quantized floor_div (#15724)
    
    As per #15148, we are adding support for quantized operations one by one. 
This PR adds support for floor_div.
---
 python/tvm/relay/frontend/tflite.py          |  6 +-----
 tests/python/frontend/tflite/test_forward.py | 13 +++++++++++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/python/tvm/relay/frontend/tflite.py 
b/python/tvm/relay/frontend/tflite.py
index 05ff630353..b33fd57b10 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -2686,11 +2686,7 @@ class OperatorConverter(object):
 
     def convert_floor_div(self, op):
         """Convert TFLite FLOOR_DIV"""
-        if self.is_quantized(op):
-            raise tvm.error.OpNotImplemented(
-                "TFlite quantized FLOOR DIV operator is not supported yet."
-            )
-        return self._convert_elemwise(_op.floor_divide, op)
+        return self._convert_elemwise(_op.floor_divide, op, 
self.is_quantized(op))
 
     def convert_floor_mod(self, op):
         """Convert TFLite FLOOR_MOD"""
diff --git a/tests/python/frontend/tflite/test_forward.py 
b/tests/python/frontend/tflite/test_forward.py
index 567139d0c2..283514a6a3 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -2747,9 +2747,16 @@ def _test_squared_difference(data, 
fused_activation_function=None, quantized=Fal
 # ------------
 
 
-def _test_floor_divide(data):
+def _test_floor_divide(data, fused_activation_function=None, quantized=False, 
qnn_op=None):
     """One iteration of floor_div"""
-    return _test_elemwise(math_ops.floordiv, data)
+    return _test_elemwise(
+        math_ops.floordiv,
+        data,
+        fused_activation_function,
+        quantized,
+        qnn_op,
+        same_qnn_params=True,
+    )
 
 
 #######################################################################
@@ -2808,6 +2815,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
         _test_equal: (-150, 150),
         _test_greater: (-150, 150),
         _test_squared_difference: (0, 65025),
+        _test_floor_divide: (-150, 150),
     }
 
     return qnn_out_range[qnn_op]
@@ -2849,6 +2857,7 @@ def test_all_elemwise():
     _test_forward_elemwise(_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)
         _test_forward_elemwise(_test_floor_mod)
 
 

Reply via email to