From 99336c34b949a5ab57ef44d6f3299b3adaa96b50 Mon Sep 17 00:00:00 2001 From: Tlopex <68688494+tlopex@users.noreply.github.com> Date: Thu, 9 Nov 2023 21:40:51 +0800 Subject: [PATCH] [TFLite][Frontend] Support quantized SQUARE (#15914) * add quantized square * add tests to quantized square --- python/tvm/relay/frontend/tflite.py | 5 ----- tests/python/frontend/tflite/test_forward.py | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/python/tvm/relay/frontend/tflite.py b/python/tvm/relay/frontend/tflite.py index cbf08da6a10f..1880887b7e65 100644 --- a/python/tvm/relay/frontend/tflite.py +++ b/python/tvm/relay/frontend/tflite.py @@ -1298,11 +1298,6 @@ def convert_square(self, op): assert len(output_tensors) == 1, "output tensors length should be 1" output_tensor = output_tensors[0] - if self.is_quantized(op): - raise tvm.error.OpNotImplemented( - "TFlite quantized SQUARE operator is not supported yet." - ) - exp_type = self.get_tensor_type_str(output_tensor.tensor.Type()) out = _op.power(in_expr, relay.const(2, exp_type)) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index d673c22adcc6..e85d370be521 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2414,7 +2414,7 @@ def test_all_unary_elemwise(): _test_forward_unary_elemwise(_test_floor) _test_forward_unary_elemwise(_test_exp) _test_forward_unary_elemwise(_test_log, negative=False) - _test_forward_unary_elemwise(_test_square) + _test_forward_unary_elemwise(_test_square, int_quant_dtype=tf.int8) _test_forward_unary_elemwise(_test_sin) _test_forward_unary_elemwise(_test_neg) _test_forward_unary_elemwise(_test_sqrt, negative=False)