Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TFLite][Frontend] Support quantized div #15768

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,9 +1429,7 @@ def convert_mul(self, op):
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"""
Expand Down
13 changes: 11 additions & 2 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


#######################################################################
Expand Down Expand Up @@ -2810,6 +2817,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),
Expand Down Expand Up @@ -2840,6 +2848,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)
Expand Down