Skip to content

Commit fe5e6e4

Browse files
authored
[TFLite][Frontend] Support quantized less (#15746)
* Update tflite.py * Update test_forward.py * Update test_forward.py
1 parent 61d5be0 commit fe5e6e4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

python/tvm/relay/frontend/tflite.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,7 @@ def convert_greater_equal(self, op):
14841484

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

14911489
def convert_less_equal(self, op):
14921490
"""Convert TFLite LESS_EQUAL"""

tests/python/frontend/tflite/test_forward.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,9 +2682,17 @@ def _test_greater_equal(data):
26822682
# ----
26832683

26842684

2685-
def _test_less(data):
2685+
def _test_less(data, fused_activation_function=None, quantized=False, qnn_op=None):
26862686
"""One iteration of less"""
2687-
return _test_elemwise(math_ops.less, data)
2687+
return _test_elemwise(
2688+
math_ops.less,
2689+
data,
2690+
fused_activation_function,
2691+
quantized,
2692+
qnn_op,
2693+
same_qnn_params=True,
2694+
comparison_op=True,
2695+
)
26882696

26892697

26902698
#######################################################################
@@ -2823,6 +2831,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
28232831
_test_greater: (-150, 150),
28242832
_test_squared_difference: (0, 65025),
28252833
_test_floor_divide: (-150, 150),
2834+
_test_less: (-150, 150),
28262835
_test_floor_mod: (-150, 150),
28272836
}
28282837

@@ -2859,6 +2868,7 @@ def test_all_elemwise():
28592868
_test_forward_elemwise_quantized(_test_squared_difference, np.int8)
28602869
_test_forward_elemwise(_test_greater_equal)
28612870
_test_forward_elemwise(_test_less)
2871+
_test_forward_elemwise_quantized(_test_less)
28622872
_test_forward_elemwise(_test_less_equal)
28632873
_test_forward_elemwise(_test_equal)
28642874
_test_forward_elemwise_quantized(_test_equal)

0 commit comments

Comments
 (0)