diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py index c80da18133601..3c3d39274dc52 100644 --- a/tests/python/frontend/tensorflow/test_forward.py +++ b/tests/python/frontend/tensorflow/test_forward.py @@ -36,6 +36,20 @@ import tvm.relay.testing.tf as tf_testing import tvm.testing +from tensorflow.python.framework import constant_op +from tensorflow.python.framework import graph_util +from tensorflow.python.ops import nn_ops +from tensorflow.python.ops import nn +from tensorflow.python.ops import array_ops +from tensorflow.python.ops import math_ops +from tensorflow.python.ops import variable_scope +from tensorflow.python.ops import variables +from tensorflow.python.ops import init_ops +from tensorflow.python.framework import function +from tensorflow.python.framework import ops +from tensorflow.python.framework import dtypes +from tensorflow.python.ops import gen_functional_ops + try: import tensorflow.compat.v1 as tf @@ -4666,7 +4680,7 @@ def _check_op(tf_op, ishape, axis, keepdims, dtype="float32"): compare_tf_with_tvm([np_data], ["in_data:0"], reduce_op.name) def _test_math_op(op, dtypes=["int32", "float32"]): - # pylint: disable=dangerous-default-value + # pylint: disable=dangerous-default-value, redefined-outer-name for dtype in dtypes: _check_op(op, (3, 10), axis=(-1), keepdims=False, dtype=dtype) _check_op(op, (8, 16, 32), axis=(-1), keepdims=False, dtype=dtype) @@ -4710,7 +4724,7 @@ def _check_op(tf_op, ishape, axis, keepdims, range_axis=False, dtype="float32"): compare_tf_with_tvm([np_data], ["in_data:0"], reduce_op.name) def _test_raw_reduce_op(op, dtypes=["int32", "float32"]): - # pylint: disable=dangerous-default-value + # pylint: disable=dangerous-default-value, redefined-outer-name for dtype in dtypes: _check_op(op, (3, 10), axis=(-1), keepdims=False, dtype=dtype) _check_op(op, (8, 16, 32), axis=(-1), keepdims=False, dtype=dtype) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index abea76acbc8ac..fc67a58e740f5 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -2234,16 +2234,28 @@ def __test_elemwise(in_data): out = math_op(inq_data[0], inq_data[1]) out = with_fused_activation_function(out, fused_activation_function) - # 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 x[0] is not None], - [x + ":0" for x in input_range.keys()], - [x[1] for x in zip(in_data, inq_data) if x[0] is not None], - [out], - quantized=True, - input_range=input_range, - experimental_new_converter=same_qnn_params, - ) + compare_tflite_with_tvm( + [x[1] for x in zip(in_data, data) if x[0] is not None], + [x + ":0" for x in input_range.keys()], + [x[1] for x in zip(in_data, inq_data) if x[0] is not None], + [out], + ) + else: + out = math_op(inq_data[0], inq_data[1]) + out = with_fused_activation_function(out, fused_activation_function) + 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 x[0] is not None], + [x + ":0" for x in input_range.keys()], + [x[1] for x in zip(in_data, inq_data) if x[0] is not None], + [out], + quantized=True, + input_range=input_range, + experimental_new_converter=same_qnn_params, + ) else: out = math_op( in_data[0] @@ -5003,6 +5015,8 @@ def test_forward_nms_v5(): # Main # ---- if __name__ == "__main__": + test_all_elemwise() + assert 0 # BatchToSpaceND test_forward_batch_to_space_nd()