Skip to content

Commit

Permalink
[TFLite][Frontend] Support quantized less (#15746)
Browse files Browse the repository at this point in the history
* Update tflite.py

* Update test_forward.py

* Update test_forward.py
  • Loading branch information
tlopex authored Sep 16, 2023
1 parent 61d5be0 commit fe5e6e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 1 addition & 3 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,7 @@ def convert_greater_equal(self, op):

def convert_less(self, op):
"""Convert TFLite LESS"""
if self.is_quantized(op):
raise tvm.error.OpNotImplemented("TFlite quantized LESS operator is not supported yet.")
return self._convert_elemwise(_op.less, op)
return self._convert_elemwise(_op.less, op, self.is_quantized(op), comparison_op=True)

def convert_less_equal(self, op):
"""Convert TFLite LESS_EQUAL"""
Expand Down
14 changes: 12 additions & 2 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2682,9 +2682,17 @@ def _test_greater_equal(data):
# ----


def _test_less(data):
def _test_less(data, fused_activation_function=None, quantized=False, qnn_op=None):
"""One iteration of less"""
return _test_elemwise(math_ops.less, data)
return _test_elemwise(
math_ops.less,
data,
fused_activation_function,
quantized,
qnn_op,
same_qnn_params=True,
comparison_op=True,
)


#######################################################################
Expand Down Expand Up @@ -2823,6 +2831,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
_test_greater: (-150, 150),
_test_squared_difference: (0, 65025),
_test_floor_divide: (-150, 150),
_test_less: (-150, 150),
_test_floor_mod: (-150, 150),
}

Expand Down Expand Up @@ -2859,6 +2868,7 @@ def test_all_elemwise():
_test_forward_elemwise_quantized(_test_squared_difference, np.int8)
_test_forward_elemwise(_test_greater_equal)
_test_forward_elemwise(_test_less)
_test_forward_elemwise_quantized(_test_less)
_test_forward_elemwise(_test_less_equal)
_test_forward_elemwise(_test_equal)
_test_forward_elemwise_quantized(_test_equal)
Expand Down

0 comments on commit fe5e6e4

Please sign in to comment.