Skip to content

Commit

Permalink
Adding support for TFLite QnnSubtract operator. apache#5230
Browse files Browse the repository at this point in the history
  • Loading branch information
shoubhik committed May 12, 2020
1 parent c3d552c commit fc63c3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ def convert_sub(self, op):
"""Convert TFLite SUB"""
# Check if the input tensor is quantized, call QNN op
if self.is_quantized(op):
raise tvm.error.OpNotImplemented(
'TFlite quantized sub operator is not supported yet.')
return self._convert_elemwise(_qnn.op.subtract, op)
return self._convert_elemwise(_op.subtract, op)

def convert_mul(self, op):
Expand Down
7 changes: 5 additions & 2 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ def test_forward_convolution():
_test_convolution([4, 17, 17, 124], [1, 1, 124, 1], [1, 1], [1, 1], 'SAME', 'NHWC', True)
_test_convolution([4, 17, 17, 12], [3, 3, 12, 1], [1, 1], [2, 2], 'VALID', 'NHWC', True)
_test_convolution([4, 17, 17, 12], [3, 3, 12, 2], [1, 1], [2, 2], 'VALID', 'NHWC', True)
# dephtwise convolution with single input channel
_test_convolution([1, 76, 64, 1], [9, 5, 1, 96], [1, 1], [1, 1], 'SAME', 'NHWC', True)


#######################################################################
Expand Down Expand Up @@ -614,9 +616,9 @@ def _test_add(data, fused_activation_function=None, quantized=False):
# Subtract
# --------

def _test_sub(data, fused_activation_function=None):
def _test_sub(data, fused_activation_function=None, quantized=False):
""" One iteration of subtract """
return _test_elemwise(math_ops.subtract, data, fused_activation_function)
return _test_elemwise(math_ops.subtract, data, fused_activation_function, quantized)
#######################################################################
# Mul
# ---
Expand Down Expand Up @@ -679,6 +681,7 @@ def test_all_elemwise():
_test_forward_elemwise(partial(_test_add, fused_activation_function="RELU"))
_test_forward_elemwise(partial(_test_add, fused_activation_function="RELU6"))
_test_forward_elemwise(_test_sub)
_test_forward_elemwise_quantized(_test_sub)
_test_forward_elemwise(partial(_test_sub, fused_activation_function="RELU"))
_test_forward_elemwise(partial(_test_sub, fused_activation_function="RELU6"))
_test_forward_elemwise(_test_mul)
Expand Down

0 comments on commit fc63c3b

Please sign in to comment.