Skip to content

Commit

Permalink
[TFLite][Frontend] Support quantized Pow (#15798)
Browse files Browse the repository at this point in the history
Support POW quantization operation as part of #15148
  • Loading branch information
tlopex authored Oct 3, 2023
1 parent 2890899 commit 646d3a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,6 @@ def convert_div(self, op):
def convert_pow(self, op):
"""Convert TFLite POW"""
# Check if the input tensor is quantized, call QNN op
if self.is_quantized(op):
raise tvm.error.OpNotImplemented("TFlite quantized POW operator is not supported yet.")
return self._convert_elemwise(_op.power, op)

def convert_maximum(self, op):
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 @@ -2627,9 +2627,16 @@ def _test_div(data, fused_activation_function=None, quantized=False, qnn_op=None
# -----


def _test_pow(data):
def _test_pow(data, fused_activation_function=None, quantized=False, qnn_op=None):
"""One iteration of power"""
return _test_elemwise(math_ops.pow, data)
return _test_elemwise(
math_ops.pow,
data,
fused_activation_function,
quantized,
qnn_op,
same_qnn_params=True,
)


#######################################################################
Expand Down Expand Up @@ -2866,6 +2873,7 @@ def _test_elemwise_qnn_out_range(qnn_op):
_test_less: (-150, 150),
_test_floor_mod: (-150, 150),
_test_not_equal: (-150, 150),
_test_pow: (0, 3),
_test_less_equal: (-150, 150),
_test_greater_equal: (-150, 150),
}
Expand Down Expand Up @@ -2894,6 +2902,7 @@ def test_all_elemwise():
_test_forward_elemwise(partial(_test_div, fused_activation_function="RELU6"))
_test_forward_elemwise_quantized(_test_div)
_test_forward_elemwise(_test_pow)
_test_forward_elemwise_quantized(_test_pow)
_test_forward_elemwise(_test_maximum)
_test_forward_elemwise_quantized(_test_maximum)
_test_forward_elemwise(_test_minimum)
Expand Down

0 comments on commit 646d3a2

Please sign in to comment.