You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by lu...@apache.org on 2023/09/18 08:44:52 UTC
[tvm] branch main updated: [TFLite][Frontend] Support quantized div (#15768)
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 47826e4d5e [TFLite][Frontend] Support quantized div (#15768)
47826e4d5e is described below
commit 47826e4d5ef7dc1298cada61fc94c5135b82cfb4
Author: Anatol Liu <an...@gmail.com>
AuthorDate: Mon Sep 18 04:44:45 2023 -0400
[TFLite][Frontend] Support quantized div (#15768)
As per #15148, adding support for div.
---
python/tvm/relay/frontend/tflite.py | 4 +---
tests/python/frontend/tflite/test_forward.py | 13 +++++++++++--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/python/tvm/relay/frontend/tflite.py b/python/tvm/relay/frontend/tflite.py
index 98920b1e49..28389d9a22 100644
--- a/python/tvm/relay/frontend/tflite.py
+++ b/python/tvm/relay/frontend/tflite.py
@@ -1429,9 +1429,7 @@ class OperatorConverter(object):
def convert_div(self, op):
"""Convert TFLite DIV"""
# Check if the input tensor is quantized, call QNN op
- if self.is_quantized(op):
- raise tvm.error.OpNotImplemented("TFlite quantized DIV operator is not supported yet.")
- return self._convert_elemwise(_op.divide, op)
+ return self._convert_elemwise(_op.divide, op, self.is_quantized(op))
def convert_pow(self, op):
"""Convert TFLite POW"""
diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py
index 1552580ff4..9917659945 100644
--- a/tests/python/frontend/tflite/test_forward.py
+++ b/tests/python/frontend/tflite/test_forward.py
@@ -2610,9 +2610,16 @@ def _test_mul(data, fused_activation_function=None, quantized=False, qnn_op=None
# ------
-def _test_div(data, fused_activation_function=None):
+def _test_div(data, fused_activation_function=None, quantized=False, qnn_op=None):
"""One iteration of divide"""
- return _test_elemwise(math_ops.divide, data, fused_activation_function)
+ return _test_elemwise(
+ math_ops.divide,
+ data,
+ fused_activation_function,
+ quantized,
+ qnn_op,
+ same_qnn_params=True,
+ )
#######################################################################
@@ -2825,6 +2832,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
_test_add: (-150, 150),
_test_sub: (-150, 150),
_test_mul: (-5e3, 5e3),
+ _test_div: (-150, 150),
_test_maximum: (-112, 111),
_test_minimum: (-128, 127),
_test_equal: (-150, 150),
@@ -2857,6 +2865,7 @@ def test_all_elemwise():
_test_forward_elemwise(_test_div)
_test_forward_elemwise(partial(_test_div, fused_activation_function="RELU"))
_test_forward_elemwise(partial(_test_div, fused_activation_function="RELU6"))
+ _test_forward_elemwise_quantized(_test_div)
_test_forward_elemwise(_test_pow)
_test_forward_elemwise(_test_maximum)
_test_forward_elemwise_quantized(_test_maximum)