diff --git a/tests/lint/pylintrc b/tests/lint/pylintrc index 1187f3ee916e2..e646736a300cc 100644 --- a/tests/lint/pylintrc +++ b/tests/lint/pylintrc @@ -106,6 +106,7 @@ disable= raise-missing-from, similarities, star-args, + superfluous-parens, super-with-arguments, suppressed-message, too-many-lines, diff --git a/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py b/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py index 42c77a9c9d2df..9224568407e1f 100644 --- a/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py +++ b/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py @@ -328,13 +328,13 @@ def test_maxpool2d_nhwc( except bu.NumericalAccuracyException as exception: print() - print(f"FAIL: Numerical accuracy error. See log file.") + print("FAIL: Numerical accuracy error. See log file.") log_file.write("\n") log_file.write(f"FAIL: {exception}\n") self.benchmark_table.record_fail( - **keys_dict, comments=f"Numerical accuracy error. See log file." + **keys_dict, comments="Numerical accuracy error. See log file." ) except bu.UnsupportedException as exception: diff --git a/tests/python/contrib/test_hexagon/test_fixed_point_conversion.py b/tests/python/contrib/test_hexagon/test_fixed_point_conversion.py index 40edbda550b7f..f31b0e24b33cb 100644 --- a/tests/python/contrib/test_hexagon/test_fixed_point_conversion.py +++ b/tests/python/contrib/test_hexagon/test_fixed_point_conversion.py @@ -27,7 +27,7 @@ import math import struct import numpy as np -import tvm.topi.hexagon.utils as utils +from tvm.topi.hexagon import utils class TestFixedPointConversion: diff --git a/tests/python/contrib/test_hexagon/test_vtcm_bandwidth.py b/tests/python/contrib/test_hexagon/test_vtcm_bandwidth.py index 53d0428a5ad1f..1ac01efcdefb3 100644 --- a/tests/python/contrib/test_hexagon/test_vtcm_bandwidth.py +++ b/tests/python/contrib/test_hexagon/test_vtcm_bandwidth.py @@ -18,9 +18,9 @@ """Test theoretical bandwith for data transfers to VTCM for different strategies.""" import numpy as np +import pytest import tvm -import pytest from tvm.script import tir as T from tvm.tir.tensor_intrin.hexagon import DMA_READ_128_i8 diff --git a/tests/python/contrib/test_hexagon/topi/test_resize2d.py b/tests/python/contrib/test_hexagon/topi/test_resize2d.py index 7d7d80fc7f7cc..4adb7c6768e71 100644 --- a/tests/python/contrib/test_hexagon/topi/test_resize2d.py +++ b/tests/python/contrib/test_hexagon/topi/test_resize2d.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# pylint: disable=unused-argument """Resize 2D tesst. """ import numpy as np diff --git a/tests/python/frontend/caffe2/test_graph.py b/tests/python/frontend/caffe2/test_graph.py index 232029c032e99..51a9a53ec057a 100644 --- a/tests/python/frontend/caffe2/test_graph.py +++ b/tests/python/frontend/caffe2/test_graph.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. """Test graph equality of caffe2 models.""" +from model_zoo import c2_squeezenet, relay_squeezenet import tvm from tvm import relay from tvm.relay import transform -from model_zoo import c2_squeezenet, relay_squeezenet def compare_graph(lhs_mod, rhs_mod): diff --git a/tests/python/frontend/coreml/test_forward.py b/tests/python/frontend/coreml/test_forward.py index 75879f3e582aa..dd1aaf30851f5 100644 --- a/tests/python/frontend/coreml/test_forward.py +++ b/tests/python/frontend/coreml/test_forward.py @@ -23,6 +23,11 @@ from enum import Enum import tempfile import numpy as np +import model_zoo +import coremltools as cm +from coremltools.models.neural_network import NeuralNetworkBuilder +from coremltools.models import datatypes +from tensorflow import keras import tvm import tvm.topi.testing @@ -30,12 +35,6 @@ from tvm.contrib import graph_executor from tvm.topi.testing import conv2d_nchw_python from tvm import relay -import model_zoo - -import coremltools as cm -from coremltools.models.neural_network import NeuralNetworkBuilder -from coremltools.models import datatypes -from tensorflow import keras def get_tvm_output( diff --git a/tests/python/frontend/keras/test_forward.py b/tests/python/frontend/keras/test_forward.py index 50fa97cbca5ce..510f242bf1bb2 100644 --- a/tests/python/frontend/keras/test_forward.py +++ b/tests/python/frontend/keras/test_forward.py @@ -16,10 +16,6 @@ # under the License. """Unit tests for various models and operators""" import numpy as np -import tvm -from tvm import relay -from tvm.contrib import graph_executor -import tvm.testing try: import tensorflow.compat.v1 as tf @@ -31,6 +27,11 @@ # prevent Keras from using up all gpu memory import keras +import tvm +from tvm import relay +from tvm.contrib import graph_executor +import tvm.testing + if tf.executing_eagerly(): GPUS = tf.config.experimental.list_physical_devices("GPU") for gpu in GPUS: diff --git a/tests/python/frontend/oneflow/test_forward.py b/tests/python/frontend/oneflow/test_forward.py index 5c68985670eac..cc9333cd03bd8 100644 --- a/tests/python/frontend/oneflow/test_forward.py +++ b/tests/python/frontend/oneflow/test_forward.py @@ -19,13 +19,12 @@ import os import numpy as np +import oneflow as flow import tvm import tvm.testing import tvm.topi.testing from tvm import relay -import oneflow as flow - MODEL_HOME = "test_model" diff --git a/tests/python/frontend/oneflow/test_vision_models.py b/tests/python/frontend/oneflow/test_vision_models.py index 8a573e0f51e31..03478dc41e33c 100644 --- a/tests/python/frontend/oneflow/test_vision_models.py +++ b/tests/python/frontend/oneflow/test_vision_models.py @@ -20,11 +20,6 @@ import os import numpy as np -import tvm -import tvm.testing -import tvm.topi.testing -from tvm import relay - import oneflow as flow from flowvision.models.alexnet import alexnet from flowvision.models.squeezenet import squeezenet1_0 @@ -32,6 +27,10 @@ from flowvision.models.mobilenet import mobilenet_v2 from flowvision.models.ghostnet import ghostnet from flowvision.models.vision_transformer import vit_base_patch16_224 +import tvm +import tvm.testing +import tvm.topi.testing +from tvm import relay MODEL_HOME = "test_model" diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py index bd966fa71ccca..2c5bd936374ca 100644 --- a/tests/python/frontend/tensorflow/test_forward.py +++ b/tests/python/frontend/tensorflow/test_forward.py @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# pylint: disable=import-self, invalid-name, unused-argument +# pylint: disable=import-self, invalid-name, unused-argument, ungrouped-imports, wrong-import-order """ Tensorflow testcases ==================== @@ -31,16 +31,6 @@ import pytest from PIL import Image -from tvm import relay, ir -from tvm.runtime.vm import VirtualMachine -from tvm.relay.frontend.tensorflow import from_tensorflow -from tvm.contrib import graph_executor -from tvm.contrib import utils -from relay.utils.tag_span import _set_span, _create_span, _verify_structural_equal_with_span - -import tvm -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 @@ -64,6 +54,17 @@ except ImportError: import tensorflow as tf +import tvm +from tvm import relay, ir +from tvm.runtime.vm import VirtualMachine +from tvm.relay.frontend.tensorflow import from_tensorflow +from tvm.contrib import graph_executor +from tvm.contrib import utils +import tvm.testing +import tvm.relay.testing.tf as tf_testing +from relay.utils.tag_span import _set_span, _create_span, _verify_structural_equal_with_span + + # Only allow TF to run on half the GPU RAM to save the other half # For TVM gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5) diff --git a/tests/python/frontend/tflite/test_forward.py b/tests/python/frontend/tflite/test_forward.py index fa4844f070bc1..3b3dcc59f057e 100644 --- a/tests/python/frontend/tflite/test_forward.py +++ b/tests/python/frontend/tflite/test_forward.py @@ -33,14 +33,7 @@ from PIL import Image -import tvm -import tvm.relay.testing.tf as tf_testing -from tvm.contrib.download import download_testdata -from tvm import relay, ir -from tvm.contrib import graph_executor from tflite.BuiltinOperator import BuiltinOperator -from relay.utils.tag_span import _set_span, _create_span, _verify_structural_equal_with_span - try: import tensorflow.compat.v1 as tf @@ -68,6 +61,13 @@ except ImportError: from tensorflow.contrib import lite as interpreter_wrapper +import tvm +import tvm.relay.testing.tf as tf_testing +from tvm.contrib.download import download_testdata +from tvm import relay, ir +from tvm.contrib import graph_executor +from relay.utils.tag_span import _set_span, _create_span, _verify_structural_equal_with_span + ####################################################################### # Generic run functions for TVM & TFLite