Skip to content

Commit

Permalink
[TFLite] Support quantized GREATER op in TFLite frontend
Browse files Browse the repository at this point in the history
Address comments
Change-Id: I0371e17031fa19a9ceebc33546cee15301c3c078
  • Loading branch information
dchauhan-arm committed Jul 20, 2022
1 parent f018434 commit 4b1339d
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2224,36 +2224,23 @@ def __test_elemwise(in_data):
if None != x[0]
}

if comparison_op:
out = math_op(inq_data[0], inq_data[1])
out = with_fused_activation_function(out, fused_activation_function)

compare_tflite_with_tvm(
[x[1] for x in zip(in_data, data) if None != x[0]],
[x + ":0" for x in input_range.keys()],
[x[1] for x in zip(in_data, inq_data) if None != x[0]],
[out],
quantized=True,
input_range=input_range,
experimental_new_converter=same_qnn_params,
)
else:
out = math_op(inq_data[0], inq_data[1])
out = with_fused_activation_function(out, fused_activation_function)
out = math_op(inq_data[0], inq_data[1])
out = with_fused_activation_function(out, fused_activation_function)
if not comparison_op:
out = tf.quantization.fake_quant_with_min_max_args(
out, min=out_min, max=out_max, name="out"
)

# Note same_qnn_params uses experimental_new_converter as toco failed
compare_tflite_with_tvm(
[x[1] for x in zip(in_data, data) if None != x[0]],
[x + ":0" for x in input_range.keys()],
[x[1] for x in zip(in_data, inq_data) if None != x[0]],
[out],
quantized=True,
input_range=input_range,
experimental_new_converter=same_qnn_params,
)
# Note same_qnn_params uses experimental_new_converter as toco failed
compare_tflite_with_tvm(
[x[1] for x in zip(in_data, data) if None != x[0]],
[x + ":0" for x in input_range.keys()],
[x[1] for x in zip(in_data, inq_data) if None != x[0]],
[out],
quantized=True,
input_range=input_range,
experimental_new_converter=same_qnn_params,
)
else:
out = math_op(
in_data[0]
Expand Down Expand Up @@ -2493,7 +2480,7 @@ def _test_forward_elemwise(testop):
)


def _test_forward_elemwise_quantized(testop, comparison_op=False):
def _test_forward_elemwise_quantized(testop):
testop(
[
np.array(np.random.uniform(0, 255, (3, 6)), dtype=np.uint8),
Expand Down Expand Up @@ -2545,11 +2532,11 @@ def test_all_elemwise():
_test_forward_elemwise(_test_squared_difference)
_test_forward_elemwise(_test_greater_equal)
_test_forward_elemwise(_test_greater)
_test_forward_elemwise_quantized(_test_greater, True)
_test_forward_elemwise_quantized(_test_greater)
_test_forward_elemwise(_test_less)
_test_forward_elemwise(_test_less_equal)
_test_forward_elemwise(_test_equal)
_test_forward_elemwise_quantized(_test_equal, True)
_test_forward_elemwise_quantized(_test_equal)
_test_forward_elemwise(_test_not_equal)
if package_version.parse(tf.VERSION) >= package_version.parse("1.14.0"):
_test_forward_elemwise(_test_floor_divide)
Expand Down

0 comments on commit 4b1339d

Please sign in to comment.