Skip to content

Commit

Permalink
fix ci test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
blackkker committed Jul 8, 2022
1 parent ccee1fa commit defc272
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
18 changes: 16 additions & 2 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
34 changes: 24 additions & 10 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit defc272

Please sign in to comment.