Skip to content

Commit

Permalink
[TFLite] Support quantized GREATER op in TFLite frontend
Browse files Browse the repository at this point in the history
Support GREATER quantization operation conversion as part of issue apache#9187
  • Loading branch information
dchauhan-arm committed May 31, 2022
1 parent efec735 commit 7f68773
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 1 addition & 6 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,12 +1399,7 @@ def convert_minimum(self, op):

def convert_greater(self, op):
"""Convert TFLite GREATER"""
# Check if the input tensor is quantized, call QNN op
if self.is_quantized(op):
raise tvm.error.OpNotImplemented(
"TFlite quantized GREATER operator is not supported yet."
)
return self._convert_elemwise(_op.greater, op)
return self._convert_elemwise(_op.greater, op, self.is_quantized(op))

def convert_squared_difference(self, op):
"""Convert TFLite SQUARED DIFFERENCE"""
Expand Down
14 changes: 10 additions & 4 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2332,9 +2332,15 @@ def _test_minimum(data, fused_activation_function=None, quantized=False, qnn_op=
# -------


def _test_greater(data):
def _test_greater(data, fused_activation_function=None, quantized=False, qnn_op=None):
"""One iteration of greater"""
return _test_elemwise(math_ops.greater, data)
return _test_elemwise(
math_ops.greater,
data,
fused_activation_function,
quantized,
qnn_op,
)


#######################################################################
Expand Down Expand Up @@ -2418,7 +2424,7 @@ def _test_floor_mod(data):


def _test_forward_elemwise(testop):
"""Elewise"""
"""Elemwise"""
testop(
[
np.arange(6.0, dtype=np.float32).reshape((2, 1, 1, 3)),
Expand Down Expand Up @@ -2486,9 +2492,9 @@ def test_all_elemwise():
_test_forward_elemwise_quantized(_test_maximum)
_test_forward_elemwise(_test_minimum)
_test_forward_elemwise_quantized(_test_minimum)
_test_forward_elemwise(_test_greater)
_test_forward_elemwise(_test_squared_difference)
_test_forward_elemwise(_test_greater_equal)
_test_forward_elemwise(_test_greater)
_test_forward_elemwise(_test_less)
_test_forward_elemwise(_test_less_equal)
_test_forward_elemwise(_test_equal)
Expand Down

0 comments on commit 7f68773

Please sign in to comment.