From d70f30009573a96ed62b905427088a54ea616019 Mon Sep 17 00:00:00 2001 From: Florin Blanaru Date: Fri, 20 May 2022 18:16:54 +0300 Subject: [PATCH] [tests] add utility to replace direct call to pytest.main --- python/tvm/testing/utils.py | 6 ++++++ tests/micro/arduino/test_arduino_error_detection.py | 3 ++- tests/micro/arduino/test_arduino_rpc_server.py | 3 ++- tests/micro/arduino/test_arduino_workflow.py | 4 +++- tests/micro/common/test_tvmc.py | 3 ++- tests/micro/zephyr/test_zephyr.py | 3 ++- tests/micro/zephyr/test_zephyr_aot.py | 2 +- tests/micro/zephyr/test_zephyr_armv7m.py | 2 +- tests/python/ci/test_ci.py | 3 ++- tests/python/contrib/test_cmsisnn/test_binary_ops.py | 2 +- tests/python/contrib/test_cmsisnn/test_conv2d.py | 2 +- tests/python/contrib/test_cmsisnn/test_extract_constants.py | 3 ++- tests/python/contrib/test_cmsisnn/test_fully_connected.py | 2 +- .../python/contrib/test_cmsisnn/test_generate_constants.py | 3 ++- tests/python/contrib/test_cmsisnn/test_networks.py | 2 +- tests/python/contrib/test_cmsisnn/test_pooling.py | 4 +--- .../contrib/test_cmsisnn/test_scalar_to_tensor_constant.py | 3 ++- tests/python/contrib/test_cmsisnn/test_softmax.py | 2 +- tests/python/contrib/test_cudnn.py | 3 ++- tests/python/contrib/test_dnnl.py | 4 +--- .../contrib/test_hexagon/conv2d/test_conv2d_blocked.py | 3 ++- .../contrib/test_hexagon/conv2d/test_conv2d_conv2d.py | 3 ++- .../python/contrib/test_hexagon/test_2d_physical_buffers.py | 2 +- tests/python/contrib/test_hexagon/test_launcher.py | 2 +- tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py | 3 ++- tests/python/contrib/test_hexagon/test_models.py | 2 +- tests/python/contrib/test_hexagon/test_usmp.py | 2 +- tests/python/contrib/test_hexagon/topi/test_batch_matmul.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_conv2d_nchw.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_conv2d_nhwc.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_dense.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_pooling.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_reduce.py | 3 ++- tests/python/contrib/test_hexagon/topi/test_softmax.py | 3 ++- tests/python/contrib/test_rpc_server_device.py | 2 +- tests/python/contrib/test_tensorrt.py | 4 +--- tests/python/contrib/test_verilator/test_verilator_ops.py | 5 ++--- tests/python/driver/tvmc/test_compiler.py | 4 +--- tests/python/driver/tvmc/test_mlf.py | 3 ++- tests/python/driver/tvmc/test_target.py | 5 ++--- tests/python/integration/test_arm_mprofile_dsp.py | 2 +- tests/python/integration/test_tuning.py | 2 +- tests/python/relay/aot/test_c_device_api.py | 3 ++- tests/python/relay/aot/test_cpp_aot.py | 2 +- tests/python/relay/aot/test_crt_aot.py | 2 +- tests/python/relay/aot/test_crt_aot_usmp.py | 5 +---- tests/python/relay/dyn/test_dynamic_op_level10.py | 5 +---- tests/python/relay/dyn/test_dynamic_op_level3.py | 4 +--- tests/python/relay/op/annotation/test_annotation.py | 5 ++--- tests/python/relay/op/test_tensor.py | 5 ++--- tests/python/relay/strategy/arm_cpu/test_conv2d_nchw.py | 2 +- tests/python/relay/strategy/arm_cpu/test_conv2d_nhwc.py | 2 +- .../python/relay/strategy/arm_cpu/test_depthwise_conv2d.py | 2 +- tests/python/relay/strategy/arm_cpu/test_group_conv2d.py | 2 +- tests/python/relay/test_any.py | 6 ++---- .../relay/test_auto_scheduler_layout_rewrite_networks.py | 2 +- tests/python/relay/test_build_module.py | 5 ++--- tests/python/relay/test_external_codegen.py | 3 ++- tests/python/relay/test_ir_parser.py | 5 ++--- tests/python/relay/test_ir_structural_equal_hash.py | 6 ++---- tests/python/relay/test_ir_text_printer.py | 6 ++---- tests/python/relay/test_op_grad_level1.py | 2 +- tests/python/relay/test_op_grad_level10.py | 2 +- tests/python/relay/test_op_level10.py | 2 +- tests/python/relay/test_op_level2.py | 2 +- tests/python/relay/test_op_level3.py | 2 +- tests/python/relay/test_op_level4.py | 2 +- tests/python/relay/test_op_level5.py | 2 +- tests/python/relay/test_op_qnn_unary_elementwise.py | 5 ++--- tests/python/relay/test_pass_annotate_spans_defuse.py | 5 +---- tests/python/relay/test_pass_dead_code_elimination.py | 5 ++--- .../python/relay/test_pass_fake_quantization_to_integer.py | 5 ++--- tests/python/relay/test_pass_flatten_atrous_conv.py | 5 ++--- tests/python/relay/test_pass_fold_constant.py | 6 ++---- tests/python/relay/test_pass_lazy_gradient_init.py | 5 +---- tests/python/relay/test_pass_manifest_lifetimes.py | 3 ++- tests/python/relay/test_pass_partial_eval.py | 6 ++---- tests/python/relay/test_pass_plan_devices.py | 5 +---- tests/python/relay/test_pass_to_a_normal_form.py | 3 ++- tests/python/relay/test_pass_to_cps.py | 6 ++---- tests/python/relay/test_prng.py | 4 +--- tests/python/relay/test_relay_te_compiler.py | 1 - tests/python/relay/test_target_hooks.py | 3 ++- tests/python/relay/test_vm.py | 4 +--- tests/python/target/test_virtual_device.py | 6 ++---- tests/python/tir/analysis/test_device_constraint_utils.py | 6 ++---- tests/python/topi/python/test_topi_conv1d_transpose_ncw.py | 2 +- tests/python/topi/python/test_topi_conv2d_int8.py | 2 +- tests/python/topi/python/test_topi_conv2d_nchw.py | 2 +- tests/python/topi/python/test_topi_conv2d_nhwc.py | 2 +- tests/python/topi/python/test_topi_correlation.py | 3 ++- tests/python/topi/python/test_topi_dense.py | 2 +- tests/python/topi/python/test_topi_depthwise_conv2d.py | 2 +- tests/python/topi/python/test_topi_loss.py | 2 +- tests/python/topi/python/test_topi_math.py | 2 +- tests/python/topi/python/test_topi_reduce.py | 2 +- tests/python/topi/python/test_topi_relu.py | 2 +- tests/python/topi/python/test_topi_softmax.py | 2 +- tests/python/topi/python/test_topi_sort.py | 2 +- tests/python/topi/python/test_topi_unique.py | 2 +- tests/python/topi/python/test_topi_vision.py | 2 +- tests/python/unittest/test_auto_scheduler_measure.py | 5 +---- .../unittest/test_auto_scheduler_sketch_generation.py | 2 +- tests/python/unittest/test_crt.py | 2 +- tests/python/unittest/test_gen_requirements.py | 3 ++- tests/python/unittest/test_index_map.py | 3 ++- tests/python/unittest/test_link_params.py | 2 +- tests/python/unittest/test_meta_schedule_builder.py | 3 ++- tests/python/unittest/test_meta_schedule_byoc_tensorrt.py | 3 ++- tests/python/unittest/test_meta_schedule_cost_model.py | 3 ++- tests/python/unittest/test_meta_schedule_database.py | 3 ++- ...est_meta_schedule_feature_extractor_per_store_feature.py | 3 ++- tests/python/unittest/test_meta_schedule_integration.py | 2 +- .../python/unittest/test_meta_schedule_post_order_apply.py | 3 ++- .../unittest/test_meta_schedule_postproc_verify_gpu_code.py | 3 ++- tests/python/unittest/test_meta_schedule_runner.py | 2 +- tests/python/unittest/test_meta_schedule_search_strategy.py | 3 ++- tests/python/unittest/test_meta_schedule_space_generator.py | 3 ++- tests/python/unittest/test_meta_schedule_task_scheduler.py | 3 ++- tests/python/unittest/test_meta_schedule_tune_context.py | 3 ++- tests/python/unittest/test_micro_model_library_format.py | 4 +--- tests/python/unittest/test_micro_project_api.py | 3 ++- tests/python/unittest/test_micro_transport.py | 2 +- tests/python/unittest/test_node_reflection.py | 3 ++- tests/python/unittest/test_runtime_graph_debug.py | 2 +- tests/python/unittest/test_runtime_profiling.py | 5 +---- tests/python/unittest/test_runtime_rpc.py | 2 +- tests/python/unittest/test_runtime_vm_profiler.py | 6 ++---- tests/python/unittest/test_target_codegen_bool.py | 3 ++- tests/python/unittest/test_target_codegen_hexagon.py | 2 +- tests/python/unittest/test_target_codegen_llvm.py | 2 +- tests/python/unittest/test_target_codegen_vulkan.py | 4 +--- tests/python/unittest/test_target_target.py | 3 ++- tests/python/unittest/test_target_texture_codegen_opencl.py | 3 ++- .../python/unittest/test_tir_analysis_estimate_tir_flops.py | 3 ++- tests/python/unittest/test_tir_renew_defs.py | 3 ++- tests/python/unittest/test_tir_schedule_block_scope.py | 3 ++- tests/python/unittest/test_tir_schedule_blockize.py | 3 ++- tests/python/unittest/test_tir_schedule_cache_read_write.py | 3 ++- tests/python/unittest/test_tir_schedule_compute_at.py | 3 ++- tests/python/unittest/test_tir_schedule_compute_inline.py | 3 ++- tests/python/unittest/test_tir_schedule_error.py | 3 ++- tests/python/unittest/test_tir_schedule_for_kind.py | 2 +- tests/python/unittest/test_tir_schedule_instruction.py | 3 ++- tests/python/unittest/test_tir_schedule_reduction.py | 2 +- tests/python/unittest/test_tir_schedule_reorder.py | 3 ++- tests/python/unittest/test_tir_schedule_rfactor.py | 2 +- tests/python/unittest/test_tir_schedule_sampling.py | 3 ++- .../python/unittest/test_tir_schedule_set_axis_separator.py | 3 ++- tests/python/unittest/test_tir_schedule_split_fuse.py | 3 ++- tests/python/unittest/test_tir_schedule_state.py | 3 ++- .../python/unittest/test_tir_schedule_state_cached_flags.py | 3 ++- tests/python/unittest/test_tir_schedule_tensorize.py | 2 +- tests/python/unittest/test_tir_schedule_trace.py | 3 ++- tests/python/unittest/test_tir_schedule_transform_layout.py | 3 ++- tests/python/unittest/test_tir_schedule_utilities.py | 3 ++- tests/python/unittest/test_tir_texture_scope.py | 3 ++- .../unittest/test_tir_transform_compact_buffer_region.py | 3 ++- .../unittest/test_tir_transform_inject_software_pipeline.py | 3 ++- .../test_tir_transform_lower_cross_thread_reduction.py | 3 ++- tests/python/unittest/test_tir_transform_storage_flatten.py | 3 ++- tests/python/unittest/test_tir_transform_storage_rewrite.py | 3 ++- .../unittest/test_tir_transform_unify_thread_binding.py | 3 ++- tests/python/unittest/test_tir_usmp_algo_hill_climb.py | 3 ++- tests/python/unittest/test_transform_layout.py | 2 +- tests/python/unittest/test_tvm_testing_features.py | 2 +- tests/python/unittest/test_tvmscript_error_report.py | 2 +- tests/python/unittest/test_tvmscript_roundtrip.py | 2 +- tests/python/unittest/test_tvmscript_syntax_sugar.py | 3 ++- 169 files changed, 265 insertions(+), 254 deletions(-) diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py index 8be5cc8ec471..0e2d7be4a14e 100644 --- a/python/tvm/testing/utils.py +++ b/python/tvm/testing/utils.py @@ -62,6 +62,7 @@ def test_something(): `TVM_TEST_TARGETS` environment variable in the CI. """ +import inspect import copy import copyreg import ctypes @@ -1513,3 +1514,8 @@ def identity_after(x, sleep): def terminate_self(): """Testing function to terminate the process.""" sys.exit(-1) + + +def main(): + test_file = inspect.getsourcefile(sys._getframe(1)) + sys.exit(pytest.main([test_file] + sys.argv[1:])) diff --git a/tests/micro/arduino/test_arduino_error_detection.py b/tests/micro/arduino/test_arduino_error_detection.py index 9db59b9259c3..583f8283ca4c 100644 --- a/tests/micro/arduino/test_arduino_error_detection.py +++ b/tests/micro/arduino/test_arduino_error_detection.py @@ -21,6 +21,7 @@ from tvm.micro.project_api.server import ServerError import test_utils +import tvm.testing # A new project and workspace dir is created for EVERY test @pytest.fixture @@ -46,4 +47,4 @@ def test_bugged_project_compile_fails(workspace_dir, project): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/arduino/test_arduino_rpc_server.py b/tests/micro/arduino/test_arduino_rpc_server.py index 1dd20597ac4e..acd4186940ac 100644 --- a/tests/micro/arduino/test_arduino_rpc_server.py +++ b/tests/micro/arduino/test_arduino_rpc_server.py @@ -29,6 +29,7 @@ import pytest import tvm +import tvm.testing from PIL import Image from tvm import relay from tvm.relay.testing import byoc @@ -367,4 +368,4 @@ def test_tensors(sess): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/arduino/test_arduino_workflow.py b/tests/micro/arduino/test_arduino_workflow.py index d566a44c0756..01bdaeb7b3b5 100644 --- a/tests/micro/arduino/test_arduino_workflow.py +++ b/tests/micro/arduino/test_arduino_workflow.py @@ -21,6 +21,8 @@ import sys import pytest +import tvm.testing + import test_utils """ @@ -218,4 +220,4 @@ def test_project_inference_runtime(serial_output): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/common/test_tvmc.py b/tests/micro/common/test_tvmc.py index a3e8a9e8b5a4..24d0213b7754 100644 --- a/tests/micro/common/test_tvmc.py +++ b/tests/micro/common/test_tvmc.py @@ -26,6 +26,7 @@ import shutil import tvm +import tvm.testing from tvm.contrib.download import download_testdata from ..zephyr.test_utils import ZEPHYR_BOARDS @@ -217,4 +218,4 @@ def test_tvmc_model_run(board, output_dir): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/zephyr/test_zephyr.py b/tests/micro/zephyr/test_zephyr.py index 49e5e2757b20..f89d11cf44dc 100644 --- a/tests/micro/zephyr/test_zephyr.py +++ b/tests/micro/zephyr/test_zephyr.py @@ -26,6 +26,7 @@ from PIL import Image import tvm +import tvm.testing import tvm.relay as relay from tvm.relay.backend import Executor, Runtime from tvm.relay.testing import byoc @@ -504,4 +505,4 @@ def test_autotune_conv2d(temp_dir, board, west_cmd, tvm_debug): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/zephyr/test_zephyr_aot.py b/tests/micro/zephyr/test_zephyr_aot.py index 6b355f28de4b..cfe2ce2ae3c8 100644 --- a/tests/micro/zephyr/test_zephyr_aot.py +++ b/tests/micro/zephyr/test_zephyr_aot.py @@ -135,4 +135,4 @@ def test_qemu_make_fail(temp_dir, board, west_cmd, tvm_debug): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/micro/zephyr/test_zephyr_armv7m.py b/tests/micro/zephyr/test_zephyr_armv7m.py index 47b78994e039..2631e4379966 100644 --- a/tests/micro/zephyr/test_zephyr_armv7m.py +++ b/tests/micro/zephyr/test_zephyr_armv7m.py @@ -187,4 +187,4 @@ def test_armv7m_intrinsic(temp_dir, board, west_cmd, tvm_debug): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/ci/test_ci.py b/tests/python/ci/test_ci.py index e197d7e48a5d..f5297c7ae7cc 100644 --- a/tests/python/ci/test_ci.py +++ b/tests/python/ci/test_ci.py @@ -20,6 +20,7 @@ import json import textwrap import pytest +import tvm.testing from test_utils import REPO_ROOT @@ -732,4 +733,4 @@ def run(type, data, check): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_binary_ops.py b/tests/python/contrib/test_cmsisnn/test_binary_ops.py index 7846bba1e089..49c76870157e 100644 --- a/tests/python/contrib/test_cmsisnn/test_binary_ops.py +++ b/tests/python/contrib/test_cmsisnn/test_binary_ops.py @@ -275,4 +275,4 @@ def test_invalid_parameters( if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_conv2d.py b/tests/python/contrib/test_cmsisnn/test_conv2d.py index 1cdf98510148..439a3ec39c9a 100644 --- a/tests/python/contrib/test_cmsisnn/test_conv2d.py +++ b/tests/python/contrib/test_cmsisnn/test_conv2d.py @@ -512,4 +512,4 @@ def test_invalid_parameters( if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_extract_constants.py b/tests/python/contrib/test_cmsisnn/test_extract_constants.py index 8e251777716a..789d400faf97 100644 --- a/tests/python/contrib/test_cmsisnn/test_extract_constants.py +++ b/tests/python/contrib/test_cmsisnn/test_extract_constants.py @@ -21,6 +21,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm import relay tvm._ffi._init_api("relay.ext.cmsisnn.transform", __name__) @@ -224,4 +225,4 @@ def test_multiple_functions_non_cmsisnn_compiler(external_compiler): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_fully_connected.py b/tests/python/contrib/test_cmsisnn/test_fully_connected.py index 111d3b2edac1..c5d97f807b04 100644 --- a/tests/python/contrib/test_cmsisnn/test_fully_connected.py +++ b/tests/python/contrib/test_cmsisnn/test_fully_connected.py @@ -234,4 +234,4 @@ def test_invalid_parameters( if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_generate_constants.py b/tests/python/contrib/test_cmsisnn/test_generate_constants.py index 1f6c76381580..cded0f03566d 100644 --- a/tests/python/contrib/test_cmsisnn/test_generate_constants.py +++ b/tests/python/contrib/test_cmsisnn/test_generate_constants.py @@ -21,6 +21,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm import relay from tvm.relay.op.contrib import cmsisnn @@ -225,4 +226,4 @@ def test_op_int8( if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_networks.py b/tests/python/contrib/test_cmsisnn/test_networks.py index fefce9e86c2d..3b1e2331f2ff 100644 --- a/tests/python/contrib/test_cmsisnn/test_networks.py +++ b/tests/python/contrib/test_cmsisnn/test_networks.py @@ -117,4 +117,4 @@ def test_cnn_small(test_runner): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_pooling.py b/tests/python/contrib/test_cmsisnn/test_pooling.py index a2650bb8d028..1fd280b7d81a 100644 --- a/tests/python/contrib/test_cmsisnn/test_pooling.py +++ b/tests/python/contrib/test_cmsisnn/test_pooling.py @@ -169,6 +169,4 @@ def test_invalid_layout(op): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_scalar_to_tensor_constant.py b/tests/python/contrib/test_cmsisnn/test_scalar_to_tensor_constant.py index 9c665053e2cf..35bdabf3171c 100644 --- a/tests/python/contrib/test_cmsisnn/test_scalar_to_tensor_constant.py +++ b/tests/python/contrib/test_cmsisnn/test_scalar_to_tensor_constant.py @@ -21,6 +21,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm import relay tvm._ffi._init_api("relay.ext.cmsisnn.transform", __name__) @@ -286,4 +287,4 @@ def get_mod(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cmsisnn/test_softmax.py b/tests/python/contrib/test_cmsisnn/test_softmax.py index 5a44a7865e66..840d0e6f4436 100644 --- a/tests/python/contrib/test_cmsisnn/test_softmax.py +++ b/tests/python/contrib/test_cmsisnn/test_softmax.py @@ -129,4 +129,4 @@ def test_invalid_parameters(in_dtype, out_dtype, zero_point, scale, out_zero_poi if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_cudnn.py b/tests/python/contrib/test_cudnn.py index cdbe424710c6..794a3d872db9 100644 --- a/tests/python/contrib/test_cudnn.py +++ b/tests/python/contrib/test_cudnn.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import te from tvm import relay from tvm.contrib import cudnn @@ -623,4 +624,4 @@ def test_relay_cudnn_conv2d_bias_act( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_dnnl.py b/tests/python/contrib/test_dnnl.py index df3f64946f75..5baf6e06d347 100755 --- a/tests/python/contrib/test_dnnl.py +++ b/tests/python/contrib/test_dnnl.py @@ -985,6 +985,4 @@ def get_graph(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/conv2d/test_conv2d_blocked.py b/tests/python/contrib/test_hexagon/conv2d/test_conv2d_blocked.py index 6762db85e628..c5df89b315b0 100644 --- a/tests/python/contrib/test_hexagon/conv2d/test_conv2d_blocked.py +++ b/tests/python/contrib/test_hexagon/conv2d/test_conv2d_blocked.py @@ -19,6 +19,7 @@ import platform import tvm +import tvm.testing from tvm import te from tvm import topi from tvm.topi import testing @@ -191,4 +192,4 @@ def test_conv2d( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/conv2d/test_conv2d_conv2d.py b/tests/python/contrib/test_hexagon/conv2d/test_conv2d_conv2d.py index 437bdb750b9d..460c824c7037 100644 --- a/tests/python/contrib/test_hexagon/conv2d/test_conv2d_conv2d.py +++ b/tests/python/contrib/test_hexagon/conv2d/test_conv2d_conv2d.py @@ -19,6 +19,7 @@ import platform import tvm +import tvm.testing from tvm import te from tvm import topi from tvm.topi import testing @@ -236,4 +237,4 @@ def test_conv2d( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py index 787d71fa1713..e9fd24656495 100644 --- a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py +++ b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py @@ -336,4 +336,4 @@ def test_execute( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_launcher.py b/tests/python/contrib/test_hexagon/test_launcher.py index 5c5e8f6c39f1..ad798925ee88 100644 --- a/tests/python/contrib/test_hexagon/test_launcher.py +++ b/tests/python/contrib/test_hexagon/test_launcher.py @@ -388,4 +388,4 @@ def test_aot_executor_multiple_conv2d(hexagon_session: Session, aot_host_target, if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py index 5fca54f47c92..23f7d6ed276c 100644 --- a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py +++ b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py @@ -18,6 +18,7 @@ import sys import tvm +import tvm.testing from tvm import te from tvm import topi from tvm.topi import testing @@ -150,4 +151,4 @@ def test_maxpool(self, shape_nhwc, window_size, stride, pad, dtype, target): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_models.py b/tests/python/contrib/test_hexagon/test_models.py index 74f52f20d97c..4fdc951574e4 100644 --- a/tests/python/contrib/test_hexagon/test_models.py +++ b/tests/python/contrib/test_hexagon/test_models.py @@ -135,4 +135,4 @@ def test_mobilenet_aot(hexagon_session: Session, aot_host_target, aot_target, en if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_usmp.py b/tests/python/contrib/test_hexagon/test_usmp.py index 03badfb655d9..9ae0feeaff21 100644 --- a/tests/python/contrib/test_hexagon/test_usmp.py +++ b/tests/python/contrib/test_hexagon/test_usmp.py @@ -109,4 +109,4 @@ def test_conv2d(hexagon_session: Session, aot_host_target, aot_target, usmp_enab if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_batch_matmul.py b/tests/python/contrib/test_hexagon/topi/test_batch_matmul.py index 093ce37e5efa..467ebd06b9cb 100644 --- a/tests/python/contrib/test_hexagon/topi/test_batch_matmul.py +++ b/tests/python/contrib/test_hexagon/topi/test_batch_matmul.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -139,4 +140,4 @@ def get_ref_data(): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_conv2d_nchw.py b/tests/python/contrib/test_hexagon/topi/test_conv2d_nchw.py index 7f530a5c4d80..c755a4d018f3 100644 --- a/tests/python/contrib/test_hexagon/topi/test_conv2d_nchw.py +++ b/tests/python/contrib/test_hexagon/topi/test_conv2d_nchw.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -242,4 +243,4 @@ class TestAsymmetricPadding(BaseConv2DTests): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_conv2d_nhwc.py b/tests/python/contrib/test_hexagon/topi/test_conv2d_nhwc.py index 74a3f8dafa3e..96062aa1b493 100644 --- a/tests/python/contrib/test_hexagon/topi/test_conv2d_nhwc.py +++ b/tests/python/contrib/test_hexagon/topi/test_conv2d_nhwc.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -121,4 +122,4 @@ class TestConv2dNHWC(BaseConv2DTests): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_dense.py b/tests/python/contrib/test_hexagon/topi/test_dense.py index 189b05fcaade..967278251cfc 100644 --- a/tests/python/contrib/test_hexagon/topi/test_dense.py +++ b/tests/python/contrib/test_hexagon/topi/test_dense.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -115,4 +116,4 @@ def test_dense( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_pooling.py b/tests/python/contrib/test_hexagon/topi/test_pooling.py index 9ce54bf9a6eb..ededdad2673b 100644 --- a/tests/python/contrib/test_hexagon/topi/test_pooling.py +++ b/tests/python/contrib/test_hexagon/topi/test_pooling.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -736,4 +737,4 @@ def test_pool3d( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_reduce.py b/tests/python/contrib/test_hexagon/topi/test_reduce.py index 203a2bd31d6e..c806964545ca 100644 --- a/tests/python/contrib/test_hexagon/topi/test_reduce.py +++ b/tests/python/contrib/test_hexagon/topi/test_reduce.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -163,4 +164,4 @@ def test_reduce_map( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/topi/test_softmax.py b/tests/python/contrib/test_hexagon/topi/test_softmax.py index 7e734af7e026..7a2435e8dcca 100644 --- a/tests/python/contrib/test_hexagon/topi/test_softmax.py +++ b/tests/python/contrib/test_hexagon/topi/test_softmax.py @@ -20,6 +20,7 @@ import sys import tvm +import tvm.testing from tvm import topi from tvm import te from tvm.contrib.hexagon.session import Session @@ -97,4 +98,4 @@ def get_ref_data(shape): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/contrib/test_rpc_server_device.py b/tests/python/contrib/test_rpc_server_device.py index 7999a05be2d9..db5459edf2c5 100644 --- a/tests/python/contrib/test_rpc_server_device.py +++ b/tests/python/contrib/test_rpc_server_device.py @@ -440,4 +440,4 @@ def test_check_auto_schedule_tuning(host, port): # pylint: disable=too-many-loc if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_tensorrt.py b/tests/python/contrib/test_tensorrt.py index 4e6aab14c06c..982ec976d54e 100644 --- a/tests/python/contrib/test_tensorrt.py +++ b/tests/python/contrib/test_tensorrt.py @@ -1402,6 +1402,4 @@ def test_empty_subgraph(run_module): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/contrib/test_verilator/test_verilator_ops.py b/tests/python/contrib/test_verilator/test_verilator_ops.py index 26d37ef10462..29d54890b367 100644 --- a/tests/python/contrib/test_verilator/test_verilator_ops.py +++ b/tests/python/contrib/test_verilator/test_verilator_ops.py @@ -19,6 +19,7 @@ import numpy as np import tvm +import tvm.testing from tvm import relay import pytest @@ -195,6 +196,4 @@ def test_bias_add(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/driver/tvmc/test_compiler.py b/tests/python/driver/tvmc/test_compiler.py index bfbf9922e0a3..d6ae27957de2 100644 --- a/tests/python/driver/tvmc/test_compiler.py +++ b/tests/python/driver/tvmc/test_compiler.py @@ -681,6 +681,4 @@ def test_compile_tflite_module_with_mod_name_and_ethosu( if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/driver/tvmc/test_mlf.py b/tests/python/driver/tvmc/test_mlf.py index 045562ad5bb6..f930f39bca92 100644 --- a/tests/python/driver/tvmc/test_mlf.py +++ b/tests/python/driver/tvmc/test_mlf.py @@ -21,6 +21,7 @@ import sys import tvm +import tvm.testing from tvm.autotvm.measure.executor import Executor from tvm.driver import tvmc from tvm.driver.tvmc.main import _main @@ -164,4 +165,4 @@ def test_tvmc_import_package_mlf_aot(tflite_mobilenet_v1_1_quant, tflite_compile if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/driver/tvmc/test_target.py b/tests/python/driver/tvmc/test_target.py index b842618efccd..4438ec437cb4 100644 --- a/tests/python/driver/tvmc/test_target.py +++ b/tests/python/driver/tvmc/test_target.py @@ -16,6 +16,7 @@ # under the License. import pytest +import tvm.testing from tvm.driver.tvmc import TVMCException from tvm.driver.tvmc.target import target_from_cli, tokenize_target, parse_target @@ -163,6 +164,4 @@ def test_parse_multiple_target_with_opts_ethos_n78(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/integration/test_arm_mprofile_dsp.py b/tests/python/integration/test_arm_mprofile_dsp.py index 7628755af4ac..2bcf284f3d77 100644 --- a/tests/python/integration/test_arm_mprofile_dsp.py +++ b/tests/python/integration/test_arm_mprofile_dsp.py @@ -349,4 +349,4 @@ def test_avgpool_1d(data_shape_ncw, pool_size, strides, padding): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/integration/test_tuning.py b/tests/python/integration/test_tuning.py index 8933fc4267cd..9581657073ae 100644 --- a/tests/python/integration/test_tuning.py +++ b/tests/python/integration/test_tuning.py @@ -219,4 +219,4 @@ def @main(%a : Tensor[(1, 3, 32, 32), float32], %b : Tensor[(3, 3, 5, 5), float3 if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/aot/test_c_device_api.py b/tests/python/relay/aot/test_c_device_api.py index 3c7db62890f5..b972b0845c30 100644 --- a/tests/python/relay/aot/test_c_device_api.py +++ b/tests/python/relay/aot/test_c_device_api.py @@ -21,6 +21,7 @@ import numpy as np import pytest import re +import tvm.testing from tvm import relay from tvm.ir.module import IRModule @@ -245,4 +246,4 @@ def test_without_device_api_packed_api(non_device_api_main_func): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/aot/test_cpp_aot.py b/tests/python/relay/aot/test_cpp_aot.py index 4a12678a79d9..04a1111e357c 100644 --- a/tests/python/relay/aot/test_cpp_aot.py +++ b/tests/python/relay/aot/test_cpp_aot.py @@ -202,4 +202,4 @@ def test_pass_wrong_device_arg(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/aot/test_crt_aot.py b/tests/python/relay/aot/test_crt_aot.py index d1d80d434b6a..83897c527c33 100644 --- a/tests/python/relay/aot/test_crt_aot.py +++ b/tests/python/relay/aot/test_crt_aot.py @@ -1073,4 +1073,4 @@ def run_before_pass(self, _, info): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/aot/test_crt_aot_usmp.py b/tests/python/relay/aot/test_crt_aot_usmp.py index 60b46d96b555..3ede2298873b 100644 --- a/tests/python/relay/aot/test_crt_aot_usmp.py +++ b/tests/python/relay/aot/test_crt_aot_usmp.py @@ -630,7 +630,4 @@ def test_u4_usecase_incompatible_interface_api_errors(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/dyn/test_dynamic_op_level10.py b/tests/python/relay/dyn/test_dynamic_op_level10.py index d34b80303b29..67be08a23935 100644 --- a/tests/python/relay/dyn/test_dynamic_op_level10.py +++ b/tests/python/relay/dyn/test_dynamic_op_level10.py @@ -151,7 +151,4 @@ def _verify(indices_shape, depth, on_value, off_value, axis, dtype): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/dyn/test_dynamic_op_level3.py b/tests/python/relay/dyn/test_dynamic_op_level3.py index 0456401e8ad2..4dece3b1a7e0 100644 --- a/tests/python/relay/dyn/test_dynamic_op_level3.py +++ b/tests/python/relay/dyn/test_dynamic_op_level3.py @@ -471,6 +471,4 @@ def @main(%x: Tensor[(?, 3), int64]) -> Tensor[(?, 3), int32] { if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/op/annotation/test_annotation.py b/tests/python/relay/op/annotation/test_annotation.py index dcbb40cdcabc..502d88ff55b6 100644 --- a/tests/python/relay/op/annotation/test_annotation.py +++ b/tests/python/relay/op/annotation/test_annotation.py @@ -16,6 +16,7 @@ # under the License. """Unit tests for annotations.""" import tvm +import tvm.testing from tvm import relay import pytest @@ -62,6 +63,4 @@ def test_on_device_free(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/op/test_tensor.py b/tests/python/relay/op/test_tensor.py index 2d561cf79eae..ceee27161cda 100644 --- a/tests/python/relay/op/test_tensor.py +++ b/tests/python/relay/op/test_tensor.py @@ -16,6 +16,7 @@ # under the License. """Unit tests for tensor helpers.""" import tvm +import tvm.testing from tvm import relay import pytest @@ -47,6 +48,4 @@ def test_device_copy_via_device(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/strategy/arm_cpu/test_conv2d_nchw.py b/tests/python/relay/strategy/arm_cpu/test_conv2d_nchw.py index e88210a59e77..6f1ea0b34a2e 100644 --- a/tests/python/relay/strategy/arm_cpu/test_conv2d_nchw.py +++ b/tests/python/relay/strategy/arm_cpu/test_conv2d_nchw.py @@ -107,4 +107,4 @@ class TestConv2d_OIHW_small_kernel(BasicConv2dTests): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/strategy/arm_cpu/test_conv2d_nhwc.py b/tests/python/relay/strategy/arm_cpu/test_conv2d_nhwc.py index f56645d43672..f5ae6f51dbd7 100644 --- a/tests/python/relay/strategy/arm_cpu/test_conv2d_nhwc.py +++ b/tests/python/relay/strategy/arm_cpu/test_conv2d_nhwc.py @@ -151,4 +151,4 @@ class TestConv2d_HWIO(BasicConv2dTests): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/strategy/arm_cpu/test_depthwise_conv2d.py b/tests/python/relay/strategy/arm_cpu/test_depthwise_conv2d.py index 89f1fb1843b4..96628a6371d0 100644 --- a/tests/python/relay/strategy/arm_cpu/test_depthwise_conv2d.py +++ b/tests/python/relay/strategy/arm_cpu/test_depthwise_conv2d.py @@ -150,4 +150,4 @@ class TestDepthwiseConv2d_NHWC_HWOI(BasicDepthwiseConv2dTests): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/strategy/arm_cpu/test_group_conv2d.py b/tests/python/relay/strategy/arm_cpu/test_group_conv2d.py index d3f504d04e35..b24c651de988 100644 --- a/tests/python/relay/strategy/arm_cpu/test_group_conv2d.py +++ b/tests/python/relay/strategy/arm_cpu/test_group_conv2d.py @@ -148,4 +148,4 @@ class TestGroupConv2d_NHWC_HWIO(BasicGroupConv2dTests): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_any.py b/tests/python/relay/test_any.py index 8ef2a0062d5a..f602a17e2412 100644 --- a/tests/python/relay/test_any.py +++ b/tests/python/relay/test_any.py @@ -18,6 +18,7 @@ import numpy as np import tvm +import tvm.testing import tvm.topi.testing from tvm import relay, te from tvm.relay.loops import while_loop @@ -2149,7 +2150,4 @@ def verify_searchsorted( if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_auto_scheduler_layout_rewrite_networks.py b/tests/python/relay/test_auto_scheduler_layout_rewrite_networks.py index f9030c525b27..54099e45a769 100644 --- a/tests/python/relay/test_auto_scheduler_layout_rewrite_networks.py +++ b/tests/python/relay/test_auto_scheduler_layout_rewrite_networks.py @@ -214,4 +214,4 @@ def test_batch_matmul(target, dev): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_build_module.py b/tests/python/relay/test_build_module.py index b03e760a968a..b25c9857de02 100644 --- a/tests/python/relay/test_build_module.py +++ b/tests/python/relay/test_build_module.py @@ -18,6 +18,7 @@ import pytest import tvm +import tvm.testing from tvm import relay from tvm.target.target import Target from tvm.relay.backend import Runtime, Executor, graph_executor_codegen @@ -82,6 +83,4 @@ def add(shape, dtype): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_external_codegen.py b/tests/python/relay/test_external_codegen.py index 41c113684f0a..c5a9041b15fe 100644 --- a/tests/python/relay/test_external_codegen.py +++ b/tests/python/relay/test_external_codegen.py @@ -22,6 +22,7 @@ import pytest import tvm +import tvm.testing from tvm import relay, runtime from tvm.relay.build_module import bind_params_by_name from tvm.relay.op.annotation import compiler_begin, compiler_end @@ -351,4 +352,4 @@ def test_load_params_with_constants_in_ext_codegen(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_ir_parser.py b/tests/python/relay/test_ir_parser.py index 7a283461e0bd..3f0b74468b21 100644 --- a/tests/python/relay/test_ir_parser.py +++ b/tests/python/relay/test_ir_parser.py @@ -18,6 +18,7 @@ import pytest import tvm +import tvm.testing from tvm import relay import tvm.relay.testing from numpy import isclose @@ -1028,6 +1029,4 @@ def @main(%x: Tensor[(2, 3), float32]) { if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_ir_structural_equal_hash.py b/tests/python/relay/test_ir_structural_equal_hash.py index dffc4189346b..a808259d26af 100644 --- a/tests/python/relay/test_ir_structural_equal_hash.py +++ b/tests/python/relay/test_ir_structural_equal_hash.py @@ -16,6 +16,7 @@ # under the License. import numpy as np import tvm +import tvm.testing from tvm import relay from tvm.relay.testing import run_opt_pass @@ -796,7 +797,4 @@ def func3(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_ir_text_printer.py b/tests/python/relay/test_ir_text_printer.py index 60f611998649..ba3b2b348acc 100644 --- a/tests/python/relay/test_ir_text_printer.py +++ b/tests/python/relay/test_ir_text_printer.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import tvm +import tvm.testing from tvm import te from tvm import relay from tvm.relay import testing @@ -307,7 +308,4 @@ def test_slash_in_identifier(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_op_grad_level1.py b/tests/python/relay/test_op_grad_level1.py index a31191a42c48..b07589d14a7a 100644 --- a/tests/python/relay/test_op_grad_level1.py +++ b/tests/python/relay/test_op_grad_level1.py @@ -213,4 +213,4 @@ def test_concatenate_grad(target, dev): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_grad_level10.py b/tests/python/relay/test_op_grad_level10.py index 4c2c9082e044..f8df64dcb9e7 100644 --- a/tests/python/relay/test_op_grad_level10.py +++ b/tests/python/relay/test_op_grad_level10.py @@ -131,4 +131,4 @@ def test_one_hot_grad(target, dev, index_dtype, val_dtype): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_level10.py b/tests/python/relay/test_op_level10.py index 8ee5adbb318d..36919e1078b5 100644 --- a/tests/python/relay/test_op_level10.py +++ b/tests/python/relay/test_op_level10.py @@ -717,4 +717,4 @@ def _verify(prediction_shape, reduction="mean", ignore_index=-100, dtype="float3 if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_op_level2.py b/tests/python/relay/test_op_level2.py index c644890bbcbe..386b0de0f6e8 100644 --- a/tests/python/relay/test_op_level2.py +++ b/tests/python/relay/test_op_level2.py @@ -1995,4 +1995,4 @@ def test_conv2d_rocm_sdot4(): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_level3.py b/tests/python/relay/test_op_level3.py index ef4b45ade9aa..895b7df9fdcf 100644 --- a/tests/python/relay/test_op_level3.py +++ b/tests/python/relay/test_op_level3.py @@ -2215,4 +2215,4 @@ def test_stft( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_level4.py b/tests/python/relay/test_op_level4.py index b9bbef951555..8d34f247b746 100644 --- a/tests/python/relay/test_op_level4.py +++ b/tests/python/relay/test_op_level4.py @@ -659,4 +659,4 @@ def verify(dshape, begin, end, strides, vshape, test_ref=True): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_level5.py b/tests/python/relay/test_op_level5.py index 10cd91415724..459a15507272 100644 --- a/tests/python/relay/test_op_level5.py +++ b/tests/python/relay/test_op_level5.py @@ -1612,4 +1612,4 @@ def verify_all_class_non_max_suppression( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/relay/test_op_qnn_unary_elementwise.py b/tests/python/relay/test_op_qnn_unary_elementwise.py index 18acc119a947..f697357871cc 100644 --- a/tests/python/relay/test_op_qnn_unary_elementwise.py +++ b/tests/python/relay/test_op_qnn_unary_elementwise.py @@ -21,6 +21,7 @@ import pytest import scipy.special import tvm +import tvm.testing from tvm import relay @@ -209,6 +210,4 @@ def test_all_numbers_int8(self): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_annotate_spans_defuse.py b/tests/python/relay/test_pass_annotate_spans_defuse.py index d6b16e70a50a..c513c592d611 100644 --- a/tests/python/relay/test_pass_annotate_spans_defuse.py +++ b/tests/python/relay/test_pass_annotate_spans_defuse.py @@ -52,7 +52,4 @@ def test_annotate_spans_compatibility(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_dead_code_elimination.py b/tests/python/relay/test_pass_dead_code_elimination.py index ff7919eb7735..8844de7567a6 100644 --- a/tests/python/relay/test_pass_dead_code_elimination.py +++ b/tests/python/relay/test_pass_dead_code_elimination.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import tvm +import tvm.testing from tvm.relay import Function, transform from tvm.relay.testing import inception_v3 import pytest @@ -347,6 +348,4 @@ def test_complexity(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_fake_quantization_to_integer.py b/tests/python/relay/test_pass_fake_quantization_to_integer.py index 5cfaa49665c8..d0c8cca6b78d 100644 --- a/tests/python/relay/test_pass_fake_quantization_to_integer.py +++ b/tests/python/relay/test_pass_fake_quantization_to_integer.py @@ -18,6 +18,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm import relay from tvm.relay.transform import fake_quantization_to_integer @@ -1017,6 +1018,4 @@ def test_fq_qat_intermediate_infertype(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_flatten_atrous_conv.py b/tests/python/relay/test_pass_flatten_atrous_conv.py index a3d3eb94aeec..39c92c5ed6c7 100644 --- a/tests/python/relay/test_pass_flatten_atrous_conv.py +++ b/tests/python/relay/test_pass_flatten_atrous_conv.py @@ -18,6 +18,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm import relay from tvm.contrib import graph_executor @@ -467,6 +468,4 @@ def test_fac_relay_build(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_fold_constant.py b/tests/python/relay/test_pass_fold_constant.py index e7235d6fcfd2..f69447d43e80 100644 --- a/tests/python/relay/test_pass_fold_constant.py +++ b/tests/python/relay/test_pass_fold_constant.py @@ -16,6 +16,7 @@ # under the License. import numpy as np import tvm +import tvm.testing from tvm import relay from tvm.relay.backend import Executor from tvm.relay import transform @@ -572,7 +573,4 @@ def expr(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_lazy_gradient_init.py b/tests/python/relay/test_pass_lazy_gradient_init.py index bc18f0a212af..323eb6aa5095 100644 --- a/tests/python/relay/test_pass_lazy_gradient_init.py +++ b/tests/python/relay/test_pass_lazy_gradient_init.py @@ -445,7 +445,4 @@ def test_ones_like(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_manifest_lifetimes.py b/tests/python/relay/test_pass_manifest_lifetimes.py index a9b038216b8e..f5b4cab20708 100644 --- a/tests/python/relay/test_pass_manifest_lifetimes.py +++ b/tests/python/relay/test_pass_manifest_lifetimes.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import tvm +import tvm.testing from tvm.relay import Function, transform from tvm.relay.testing import inception_v3 import pytest @@ -144,4 +145,4 @@ def @main(%x: int) { if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_partial_eval.py b/tests/python/relay/test_pass_partial_eval.py index 84ecc8477e50..bec9041e4688 100644 --- a/tests/python/relay/test_pass_partial_eval.py +++ b/tests/python/relay/test_pass_partial_eval.py @@ -17,6 +17,7 @@ import numpy as np import tvm +import tvm.testing from tvm import relay from tvm.relay.prelude import Prelude from tvm.relay import op, create_executor, transform @@ -350,7 +351,4 @@ def test_tuple_match(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_plan_devices.py b/tests/python/relay/test_pass_plan_devices.py index e485b626b4da..1158be0037d5 100644 --- a/tests/python/relay/test_pass_plan_devices.py +++ b/tests/python/relay/test_pass_plan_devices.py @@ -1703,7 +1703,4 @@ def @main(%a: Tensor[(5, 7), float32], %b: Tensor[(5, 7), float32], if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_to_a_normal_form.py b/tests/python/relay/test_pass_to_a_normal_form.py index f44f2a99258b..70971d243c97 100644 --- a/tests/python/relay/test_pass_to_a_normal_form.py +++ b/tests/python/relay/test_pass_to_a_normal_form.py @@ -18,6 +18,7 @@ import sys import numpy as np import tvm +import tvm.testing from tvm import te from tvm import relay from tvm.relay.analysis import detect_feature @@ -228,4 +229,4 @@ def test_gradient_if(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_pass_to_cps.py b/tests/python/relay/test_pass_to_cps.py index 2200320c448b..d0a29aff7749 100644 --- a/tests/python/relay/test_pass_to_cps.py +++ b/tests/python/relay/test_pass_to_cps.py @@ -16,6 +16,7 @@ # under the License. import numpy as np import tvm +import tvm.testing from tvm import relay from tvm.relay.analysis import detect_feature from tvm.relay.transform import to_cps, un_cps @@ -123,7 +124,4 @@ def destroy_ref(x): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_prng.py b/tests/python/relay/test_prng.py index 29e271b1c4d7..7e62ee8a75c8 100644 --- a/tests/python/relay/test_prng.py +++ b/tests/python/relay/test_prng.py @@ -166,6 +166,4 @@ def test_threefry_generate_out_size(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_relay_te_compiler.py b/tests/python/relay/test_relay_te_compiler.py index e200e79c1532..16041f00cc12 100644 --- a/tests/python/relay/test_relay_te_compiler.py +++ b/tests/python/relay/test_relay_te_compiler.py @@ -24,7 +24,6 @@ from tvm.relay.backend import te_compiler from tvm.relay.testing import run_infer_type from tvm.relay.testing.temp_op_attr import TempOpAttr -import tvm.testing @autotvm.register_topi_compute("test/conv2d_1") diff --git a/tests/python/relay/test_target_hooks.py b/tests/python/relay/test_target_hooks.py index 5856dc1e1c69..22b3b8cb3063 100644 --- a/tests/python/relay/test_target_hooks.py +++ b/tests/python/relay/test_target_hooks.py @@ -19,6 +19,7 @@ import numpy as np import pytest +import tvm.testing from tvm import relay, IRModule from utils.external_codegen import ( @@ -73,4 +74,4 @@ def test_runtime_module_generation(check_result): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/relay/test_vm.py b/tests/python/relay/test_vm.py index e05e84d2ec35..4f649ad9beba 100644 --- a/tests/python/relay/test_vm.py +++ b/tests/python/relay/test_vm.py @@ -1406,6 +1406,4 @@ def test_vm_save_and_load_without_designating_late_bound_consts(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/target/test_virtual_device.py b/tests/python/target/test_virtual_device.py index 392e41855625..a6434480fa83 100644 --- a/tests/python/target/test_virtual_device.py +++ b/tests/python/target/test_virtual_device.py @@ -16,6 +16,7 @@ # under the License. import pytest import tvm +import tvm.testing def test_make_virtual_device_for_device(): @@ -45,7 +46,4 @@ def test_make_virtual_device_for_device_target_and_memory_scope(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/tir/analysis/test_device_constraint_utils.py b/tests/python/tir/analysis/test_device_constraint_utils.py index 65cb4e398294..9dcf47230009 100644 --- a/tests/python/tir/analysis/test_device_constraint_utils.py +++ b/tests/python/tir/analysis/test_device_constraint_utils.py @@ -16,6 +16,7 @@ # under the License. """Test retrieving and applying memory scope constraints to PrimFuncs""" import tvm +import tvm.testing from tvm import tir from tvm import relay from tvm.script import tir as T @@ -64,7 +65,4 @@ def test_apply_prim_func_arg_and_result_memory_constraints(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_conv1d_transpose_ncw.py b/tests/python/topi/python/test_topi_conv1d_transpose_ncw.py index 93cfecf4239d..aa14f739a8bd 100644 --- a/tests/python/topi/python/test_topi_conv1d_transpose_ncw.py +++ b/tests/python/topi/python/test_topi_conv1d_transpose_ncw.py @@ -118,4 +118,4 @@ def test_conv1d_transpose_ncw( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_conv2d_int8.py b/tests/python/topi/python/test_topi_conv2d_int8.py index 17c5573b2c70..6070cafa9c2c 100644 --- a/tests/python/topi/python/test_topi_conv2d_int8.py +++ b/tests/python/topi/python/test_topi_conv2d_int8.py @@ -674,4 +674,4 @@ def test_conv2d_nhwc(): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_conv2d_nchw.py b/tests/python/topi/python/test_topi_conv2d_nchw.py index 96a7ff9b926c..e0c0b830b5f2 100644 --- a/tests/python/topi/python/test_topi_conv2d_nchw.py +++ b/tests/python/topi/python/test_topi_conv2d_nchw.py @@ -351,4 +351,4 @@ class TestBiasRelu(BaseConv2DTests): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_conv2d_nhwc.py b/tests/python/topi/python/test_topi_conv2d_nhwc.py index 8c125af72163..362de3a76909 100644 --- a/tests/python/topi/python/test_topi_conv2d_nhwc.py +++ b/tests/python/topi/python/test_topi_conv2d_nhwc.py @@ -96,4 +96,4 @@ def test_conv2d_nhwc(target, dev, ref_data, dtype, stride, padding, dilation): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_correlation.py b/tests/python/topi/python/test_topi_correlation.py index 3dff54dfa694..6592e9bdad07 100644 --- a/tests/python/topi/python/test_topi_correlation.py +++ b/tests/python/topi/python/test_topi_correlation.py @@ -21,6 +21,7 @@ import pytest import tvm +import tvm.testing import tvm.topi.testing from tvm import autotvm, te, topi @@ -93,4 +94,4 @@ def test_correlation_nchw( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_dense.py b/tests/python/topi/python/test_topi_dense.py index 2826d70ba0ed..7e65e2449fd7 100644 --- a/tests/python/topi/python/test_topi_dense.py +++ b/tests/python/topi/python/test_topi_dense.py @@ -181,4 +181,4 @@ def test_dense_cuda_int8( if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_depthwise_conv2d.py b/tests/python/topi/python/test_topi_depthwise_conv2d.py index 24c232129c91..a4bfbbfe8ec3 100644 --- a/tests/python/topi/python/test_topi_depthwise_conv2d.py +++ b/tests/python/topi/python/test_topi_depthwise_conv2d.py @@ -438,4 +438,4 @@ class TestDepthwiseConv2DArmCompile(BaseDepthwiseConv2D): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_loss.py b/tests/python/topi/python/test_topi_loss.py index c1b61e5b49cd..53960139dd2e 100644 --- a/tests/python/topi/python/test_topi_loss.py +++ b/tests/python/topi/python/test_topi_loss.py @@ -65,4 +65,4 @@ def test_nll_loss(target, dev, prediction_shape, reduction, ignore_index, dtype) if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_math.py b/tests/python/topi/python/test_topi_math.py index 5ee049fa379a..e8552505139a 100644 --- a/tests/python/topi/python/test_topi_math.py +++ b/tests/python/topi/python/test_topi_math.py @@ -237,4 +237,4 @@ def test_cast(target, dev, cast_ref_data, from_dtype, to_dtype): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_reduce.py b/tests/python/topi/python/test_topi_reduce.py index 23d762c5002a..e7f47ba0c4db 100644 --- a/tests/python/topi/python/test_topi_reduce.py +++ b/tests/python/topi/python/test_topi_reduce.py @@ -184,4 +184,4 @@ def test_complex_reduce(target, dev): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_relu.py b/tests/python/topi/python/test_topi_relu.py index d2d790e33d85..948835068902 100644 --- a/tests/python/topi/python/test_topi_relu.py +++ b/tests/python/topi/python/test_topi_relu.py @@ -113,4 +113,4 @@ def _prelu_numpy(x, W): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_softmax.py b/tests/python/topi/python/test_topi_softmax.py index 97fbedcc288e..cd73c660e8be 100644 --- a/tests/python/topi/python/test_topi_softmax.py +++ b/tests/python/topi/python/test_topi_softmax.py @@ -105,4 +105,4 @@ def test_softmax(target, dev, shape, dtype, ref_data, softmax_operation): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_sort.py b/tests/python/topi/python/test_topi_sort.py index 43c6ce88be76..a23b4566a2da 100644 --- a/tests/python/topi/python/test_topi_sort.py +++ b/tests/python/topi/python/test_topi_sort.py @@ -159,4 +159,4 @@ def test_topk(target, dev, topk, axis, topk_ret_type, is_ascend, dtype): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_unique.py b/tests/python/topi/python/test_topi_unique.py index 4dd9b193ad57..e2a82f64aecb 100644 --- a/tests/python/topi/python/test_topi_unique.py +++ b/tests/python/topi/python/test_topi_unique.py @@ -111,4 +111,4 @@ def calc_numpy_unique(data, is_sorted=False): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/topi/python/test_topi_vision.py b/tests/python/topi/python/test_topi_vision.py index 6ddb86f4027f..5cc064944b63 100644 --- a/tests/python/topi/python/test_topi_vision.py +++ b/tests/python/topi/python/test_topi_vision.py @@ -717,4 +717,4 @@ def test_all_class_non_max_suppression(target, dev): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_auto_scheduler_measure.py b/tests/python/unittest/test_auto_scheduler_measure.py index 04879573bd6a..3fd5f97dd8a3 100644 --- a/tests/python/unittest/test_auto_scheduler_measure.py +++ b/tests/python/unittest/test_auto_scheduler_measure.py @@ -424,7 +424,4 @@ def foo(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_auto_scheduler_sketch_generation.py b/tests/python/unittest/test_auto_scheduler_sketch_generation.py index 6d2f870ca14d..a3f63a38495c 100644 --- a/tests/python/unittest/test_auto_scheduler_sketch_generation.py +++ b/tests/python/unittest/test_auto_scheduler_sketch_generation.py @@ -451,4 +451,4 @@ def test_cuda_zero_rank_sketch(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_crt.py b/tests/python/unittest/test_crt.py index d5611906fc5d..84bb17bf7d44 100644 --- a/tests/python/unittest/test_crt.py +++ b/tests/python/unittest/test_crt.py @@ -400,4 +400,4 @@ def test_autotune(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_gen_requirements.py b/tests/python/unittest/test_gen_requirements.py index 1f6388ba3c76..05223c3f4396 100644 --- a/tests/python/unittest/test_gen_requirements.py +++ b/tests/python/unittest/test_gen_requirements.py @@ -24,6 +24,7 @@ import sys import tvm +import tvm.testing import pytest @@ -217,4 +218,4 @@ def test_semver(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_index_map.py b/tests/python/unittest/test_index_map.py index a8f5204f0202..bb4e429d6453 100644 --- a/tests/python/unittest/test_index_map.py +++ b/tests/python/unittest/test_index_map.py @@ -18,6 +18,7 @@ import pytest import tvm +import tvm.testing from tvm.tir import IndexMap from tvm.ir import assert_structural_equal @@ -186,4 +187,4 @@ def test_nonsurjective_inverse(padding_test_case): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_link_params.py b/tests/python/unittest/test_link_params.py index ea4f4ff975d7..afa745760895 100644 --- a/tests/python/unittest/test_link_params.py +++ b/tests/python/unittest/test_link_params.py @@ -382,4 +382,4 @@ def _run_unlinked(lib): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_builder.py b/tests/python/unittest/test_meta_schedule_builder.py index af95ea57e34a..a74ac893262f 100644 --- a/tests/python/unittest/test_meta_schedule_builder.py +++ b/tests/python/unittest/test_meta_schedule_builder.py @@ -22,6 +22,7 @@ from typing import List import pytest +import tvm.testing from tvm import script from tvm._ffi import register_func @@ -225,4 +226,4 @@ def test_meta_schedule_missing_build_func(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_byoc_tensorrt.py b/tests/python/unittest/test_meta_schedule_byoc_tensorrt.py index 91e2c41b2b3c..21f56cc912ef 100644 --- a/tests/python/unittest/test_meta_schedule_byoc_tensorrt.py +++ b/tests/python/unittest/test_meta_schedule_byoc_tensorrt.py @@ -22,6 +22,7 @@ import pytest import tvm +import tvm.testing from tvm import relay from tvm.meta_schedule.arg_info import TensorInfo from tvm.meta_schedule.builder import BuilderInput, LocalBuilder @@ -168,4 +169,4 @@ def test_relay_model(model_name: str, input_shape: List[int], use_trt: bool): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_cost_model.py b/tests/python/unittest/test_meta_schedule_cost_model.py index 621cf5f3264b..d1d558181324 100644 --- a/tests/python/unittest/test_meta_schedule_cost_model.py +++ b/tests/python/unittest/test_meta_schedule_cost_model.py @@ -25,6 +25,7 @@ import numpy as np import pytest import tvm +import tvm.testing from tvm.meta_schedule.cost_model import PyCostModel, RandomModel, XGBModel from tvm.meta_schedule.feature_extractor import RandomFeatureExtractor from tvm.meta_schedule.runner import RunnerResult @@ -228,4 +229,4 @@ def test_meta_schedule_xgb_model_reupdate(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_database.py b/tests/python/unittest/test_meta_schedule_database.py index cb7761aefecc..d494f997c1ce 100644 --- a/tests/python/unittest/test_meta_schedule_database.py +++ b/tests/python/unittest/test_meta_schedule_database.py @@ -23,6 +23,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.ir.module import IRModule from tvm.meta_schedule.arg_info import ArgInfo @@ -296,4 +297,4 @@ def test_meta_schedule_database_reload(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_feature_extractor_per_store_feature.py b/tests/python/unittest/test_meta_schedule_feature_extractor_per_store_feature.py index 1ce477924631..17ea8b9d3bb5 100644 --- a/tests/python/unittest/test_meta_schedule_feature_extractor_per_store_feature.py +++ b/tests/python/unittest/test_meta_schedule_feature_extractor_per_store_feature.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from numpy.testing import assert_allclose from tvm import meta_schedule as ms from tvm import te, tir @@ -1588,4 +1589,4 @@ def test_cpu_layout_transform(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_integration.py b/tests/python/unittest/test_meta_schedule_integration.py index b17d6ffc6054..cd6e1b4c405a 100644 --- a/tests/python/unittest/test_meta_schedule_integration.py +++ b/tests/python/unittest/test_meta_schedule_integration.py @@ -286,4 +286,4 @@ def test_extract_task_arm_conv2d_nchwc(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_post_order_apply.py b/tests/python/unittest/test_meta_schedule_post_order_apply.py index e20da435f972..c5b6adb466e2 100644 --- a/tests/python/unittest/test_meta_schedule_post_order_apply.py +++ b/tests/python/unittest/test_meta_schedule_post_order_apply.py @@ -22,6 +22,7 @@ import pytest import tvm +import tvm.testing from tvm._ffi import register_func from tvm.error import TVMError from tvm.meta_schedule import TuneContext @@ -388,4 +389,4 @@ def custom_search_space_func(sch: Schedule, _: BlockRV) -> List[Schedule]: if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py b/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py index 041f641a45d2..a1d2bcfcde08 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py +++ b/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.meta_schedule import TuneContext from tvm.meta_schedule.postproc import VerifyGPUCode @@ -452,4 +453,4 @@ def test_postproc_verify_gpu_6(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_runner.py b/tests/python/unittest/test_meta_schedule_runner.py index 09e708f32f42..a79498304b2f 100644 --- a/tests/python/unittest/test_meta_schedule_runner.py +++ b/tests/python/unittest/test_meta_schedule_runner.py @@ -890,4 +890,4 @@ def test_run_evaluator( if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_search_strategy.py b/tests/python/unittest/test_meta_schedule_search_strategy.py index b148f58ff804..94042dd753e0 100644 --- a/tests/python/unittest/test_meta_schedule_search_strategy.py +++ b/tests/python/unittest/test_meta_schedule_search_strategy.py @@ -21,6 +21,7 @@ import pytest import tvm +import tvm.testing from tvm import meta_schedule as ms from tvm.meta_schedule import TuneContext from tvm.meta_schedule.runner import RunnerResult @@ -242,4 +243,4 @@ def _schedule_matmul_empty(sch: Schedule): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_space_generator.py b/tests/python/unittest/test_meta_schedule_space_generator.py index 4e20524f06a5..84104c8bcff2 100644 --- a/tests/python/unittest/test_meta_schedule_space_generator.py +++ b/tests/python/unittest/test_meta_schedule_space_generator.py @@ -23,6 +23,7 @@ import pytest import tvm +import tvm.testing from tvm.meta_schedule.utils import derived_object from tvm.meta_schedule.space_generator import ScheduleFn, PySpaceGenerator, SpaceGeneratorUnion from tvm.meta_schedule.tune_context import TuneContext @@ -101,4 +102,4 @@ class TestPySpaceGenerator(PySpaceGenerator): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_task_scheduler.py b/tests/python/unittest/test_meta_schedule_task_scheduler.py index fdf4d26379ae..025bbe4225b5 100644 --- a/tests/python/unittest/test_meta_schedule_task_scheduler.py +++ b/tests/python/unittest/test_meta_schedule_task_scheduler.py @@ -23,6 +23,7 @@ import pytest import tvm +import tvm.testing from tvm._ffi.base import TVMError from tvm.meta_schedule import TuneContext, measure_callback from tvm.meta_schedule.search_strategy import ReplayTrace @@ -365,4 +366,4 @@ def test_meta_schedule_task_scheduler_multiple_gradient_based(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_meta_schedule_tune_context.py b/tests/python/unittest/test_meta_schedule_tune_context.py index 01a4379e5127..69b38c82a11f 100644 --- a/tests/python/unittest/test_meta_schedule_tune_context.py +++ b/tests/python/unittest/test_meta_schedule_tune_context.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm.script import tir as T from tvm.target import Target from tvm.meta_schedule import TuneContext @@ -56,4 +57,4 @@ def test_tune_context_create(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_micro_model_library_format.py b/tests/python/unittest/test_micro_model_library_format.py index 76e95c960482..f60e5aa227c0 100644 --- a/tests/python/unittest/test_micro_model_library_format.py +++ b/tests/python/unittest/test_micro_model_library_format.py @@ -429,6 +429,4 @@ def test_export_byoc_c_module(): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_micro_project_api.py b/tests/python/unittest/test_micro_project_api.py index 1dd8940fecec..569393c06094 100644 --- a/tests/python/unittest/test_micro_project_api.py +++ b/tests/python/unittest/test_micro_project_api.py @@ -25,6 +25,7 @@ import pytest import tvm +import tvm.testing # Implementing as a fixture so that the tvm.micro import doesn't occur @@ -494,4 +495,4 @@ def _request_reply(request): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_micro_transport.py b/tests/python/unittest/test_micro_transport.py index 2fbfada198e3..804f83587f00 100644 --- a/tests/python/unittest/test_micro_transport.py +++ b/tests/python/unittest/test_micro_transport.py @@ -222,4 +222,4 @@ def test_write_keyboard_interrupt(transport, transport_logger, get_latest_log): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_node_reflection.py b/tests/python/unittest/test_node_reflection.py index bb300607cfd6..595067866f82 100644 --- a/tests/python/unittest/test_node_reflection.py +++ b/tests/python/unittest/test_node_reflection.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import tvm +import tvm.testing import sys import pytest from tvm import te @@ -195,4 +196,4 @@ def test_alloc_const(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_runtime_graph_debug.py b/tests/python/unittest/test_runtime_graph_debug.py index 9d7bedecab71..904e5820e3ec 100644 --- a/tests/python/unittest/test_runtime_graph_debug.py +++ b/tests/python/unittest/test_runtime_graph_debug.py @@ -256,4 +256,4 @@ def test_run_single_node(graph, n, A, myadd): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_runtime_profiling.py b/tests/python/unittest/test_runtime_profiling.py index 3cc79ab67a2a..919057f08d27 100644 --- a/tests/python/unittest/test_runtime_profiling.py +++ b/tests/python/unittest/test_runtime_profiling.py @@ -358,7 +358,4 @@ def test_roofline_analysis_rpc(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_runtime_rpc.py b/tests/python/unittest/test_runtime_rpc.py index 63be742fdbb9..255d28a5eff2 100644 --- a/tests/python/unittest/test_runtime_rpc.py +++ b/tests/python/unittest/test_runtime_rpc.py @@ -34,7 +34,7 @@ if __name__ == "__main__": # NOTE: must live here to avoid registering PackedFunc with libtvm.so twice. - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() # tkonolige: The issue as I understand it is this: multiprocessing's spawn diff --git a/tests/python/unittest/test_runtime_vm_profiler.py b/tests/python/unittest/test_runtime_vm_profiler.py index 45bce024e368..3559e11f8e72 100644 --- a/tests/python/unittest/test_runtime_vm_profiler.py +++ b/tests/python/unittest/test_runtime_vm_profiler.py @@ -17,6 +17,7 @@ import numpy as np import tvm +import tvm.testing from tvm.runtime import profiler_vm from tvm import relay from tvm.relay.testing import mlp @@ -54,7 +55,4 @@ def test_vm_reshape_and_copy(): if __name__ == "__main__": - import sys - import pytest - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_codegen_bool.py b/tests/python/unittest/test_target_codegen_bool.py index 0b6616537430..b9f4437110c8 100644 --- a/tests/python/unittest/test_target_codegen_bool.py +++ b/tests/python/unittest/test_target_codegen_bool.py @@ -17,6 +17,7 @@ """codegen related to bool types""" import tvm +import tvm.testing from tvm import te import numpy as np import tvm.testing @@ -71,4 +72,4 @@ def test_cmp_load_store(target, dev, arr_size, compute, schedule): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_codegen_hexagon.py b/tests/python/unittest/test_target_codegen_hexagon.py index 41f0cb162098..344c7a976248 100644 --- a/tests/python/unittest/test_target_codegen_hexagon.py +++ b/tests/python/unittest/test_target_codegen_hexagon.py @@ -116,4 +116,4 @@ def test_llvm_options(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_codegen_llvm.py b/tests/python/unittest/test_target_codegen_llvm.py index 0feab2488423..df2a394b16eb 100644 --- a/tests/python/unittest/test_target_codegen_llvm.py +++ b/tests/python/unittest/test_target_codegen_llvm.py @@ -977,4 +977,4 @@ def test_llvm_target_attributes(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_codegen_vulkan.py b/tests/python/unittest/test_target_codegen_vulkan.py index 931aee33b4b5..3b42dd61dca2 100644 --- a/tests/python/unittest/test_target_codegen_vulkan.py +++ b/tests/python/unittest/test_target_codegen_vulkan.py @@ -554,6 +554,4 @@ def do_compute(ins, outs): if __name__ == "__main__": - import sys - - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_target.py b/tests/python/unittest/test_target_target.py index 9f5f62b8b991..2d461fe77dec 100644 --- a/tests/python/unittest/test_target_target.py +++ b/tests/python/unittest/test_target_target.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm.target import Target, arm_cpu, bifrost, cuda, intel_graphics, mali, rocm, vta @@ -455,4 +456,4 @@ def test_target_attr_bool_value(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_target_texture_codegen_opencl.py b/tests/python/unittest/test_target_texture_codegen_opencl.py index acfadc9d51ad..06876258e5d1 100644 --- a/tests/python/unittest/test_target_texture_codegen_opencl.py +++ b/tests/python/unittest/test_target_texture_codegen_opencl.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import autotvm from tvm import te from tvm.topi import testing @@ -1397,4 +1398,4 @@ class TestDepthwiseConv2dNCHWcKCRSk(BaseConv2DValidator): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_analysis_estimate_tir_flops.py b/tests/python/unittest/test_tir_analysis_estimate_tir_flops.py index a516f07473f0..7aa015831a32 100644 --- a/tests/python/unittest/test_tir_analysis_estimate_tir_flops.py +++ b/tests/python/unittest/test_tir_analysis_estimate_tir_flops.py @@ -18,6 +18,7 @@ import sys import pytest +import tvm.testing from tvm.ir import IRModule from tvm.meta_schedule.testing.te_workload import create_te_workload from tvm.tir.analysis import estimate_tir_flops @@ -48,4 +49,4 @@ def test_te_workload(workload, flops): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_renew_defs.py b/tests/python/unittest/test_tir_renew_defs.py index 26e41477e252..36cc52c16935 100644 --- a/tests/python/unittest/test_tir_renew_defs.py +++ b/tests/python/unittest/test_tir_renew_defs.py @@ -19,6 +19,7 @@ import sys import tvm +import tvm.testing from tvm.script import tir as T from tvm.tir.buffer import Buffer from tvm.tir.function import PrimFunc @@ -168,4 +169,4 @@ def symbolic_func(a: T.handle, b: T.handle, n: T.int32): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_block_scope.py b/tests/python/unittest/test_tir_schedule_block_scope.py index ad789a010745..375b6c07c2bb 100644 --- a/tests/python/unittest/test_tir_schedule_block_scope.py +++ b/tests/python/unittest/test_tir_schedule_block_scope.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule import DepKind @@ -151,4 +152,4 @@ def test_war_dependency(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_blockize.py b/tests/python/unittest/test_tir_schedule_blockize.py index b4a16a8231b8..481421cfdf78 100644 --- a/tests/python/unittest/test_tir_schedule_blockize.py +++ b/tests/python/unittest/test_tir_schedule_blockize.py @@ -18,6 +18,7 @@ import sys import pytest import tvm +import tvm.testing from tvm.script import tir as T from tvm import tir from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -207,4 +208,4 @@ def test_blockize_init_loops(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_cache_read_write.py b/tests/python/unittest/test_tir_schedule_cache_read_write.py index 5ecf615e0151..ef306b2c4929 100644 --- a/tests/python/unittest/test_tir_schedule_cache_read_write.py +++ b/tests/python/unittest/test_tir_schedule_cache_read_write.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -925,4 +926,4 @@ def test_cache_write_fail_invalid_storage_scope(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_compute_at.py b/tests/python/unittest/test_tir_schedule_compute_at.py index 25b69aa6de19..b06dcebe1d1c 100644 --- a/tests/python/unittest/test_tir_schedule_compute_at.py +++ b/tests/python/unittest/test_tir_schedule_compute_at.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -1297,4 +1298,4 @@ def test_fail_all_producers_under_loop(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_compute_inline.py b/tests/python/unittest/test_tir_schedule_compute_inline.py index 057d808ca4ec..28a83d8eefe7 100644 --- a/tests/python/unittest/test_tir_schedule_compute_inline.py +++ b/tests/python/unittest/test_tir_schedule_compute_inline.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -737,4 +738,4 @@ def test_compute_inline_opaque_access_with_tvm_access_ptr(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_error.py b/tests/python/unittest/test_tir_schedule_error.py index 15e13c47e0bf..99de5305fdd5 100644 --- a/tests/python/unittest/test_tir_schedule_error.py +++ b/tests/python/unittest/test_tir_schedule_error.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T @@ -74,4 +75,4 @@ def test_tir_schedule_attribute_error(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_for_kind.py b/tests/python/unittest/test_tir_schedule_for_kind.py index 00d97c7339ee..132e8b8b3fa5 100644 --- a/tests/python/unittest/test_tir_schedule_for_kind.py +++ b/tests/python/unittest/test_tir_schedule_for_kind.py @@ -656,4 +656,4 @@ def test_scatter_parallelize(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_instruction.py b/tests/python/unittest/test_tir_schedule_instruction.py index 9e6f447dd3e6..1aa78ee68c5b 100644 --- a/tests/python/unittest/test_tir_schedule_instruction.py +++ b/tests/python/unittest/test_tir_schedule_instruction.py @@ -19,6 +19,7 @@ import sys import pytest +import tvm.testing from tvm.tir.schedule import BlockRV, Instruction, InstructionKind, LoopRV @@ -65,4 +66,4 @@ def test_inst_construct_2(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_reduction.py b/tests/python/unittest/test_tir_schedule_reduction.py index 4be8ebc2c296..a8348afb457d 100644 --- a/tests/python/unittest/test_tir_schedule_reduction.py +++ b/tests/python/unittest/test_tir_schedule_reduction.py @@ -295,4 +295,4 @@ def test_decompose_reduction_ref_hash_check(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_reorder.py b/tests/python/unittest/test_tir_schedule_reorder.py index 462099e6fe15..c5663a5f2ebd 100644 --- a/tests/python/unittest/test_tir_schedule_reorder.py +++ b/tests/python/unittest/test_tir_schedule_reorder.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -368,4 +369,4 @@ def test_reorder_fail_not_affine_bindings(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_rfactor.py b/tests/python/unittest/test_tir_schedule_rfactor.py index a533668023b7..4078b1e89682 100644 --- a/tests/python/unittest/test_tir_schedule_rfactor.py +++ b/tests/python/unittest/test_tir_schedule_rfactor.py @@ -858,4 +858,4 @@ def test_reduction_rfactor_spatial_only(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_sampling.py b/tests/python/unittest/test_tir_schedule_sampling.py index d8f9670250ed..17f35ea8f72f 100644 --- a/tests/python/unittest/test_tir_schedule_sampling.py +++ b/tests/python/unittest/test_tir_schedule_sampling.py @@ -19,6 +19,7 @@ import numpy import pytest +import tvm.testing from tvm import tir from tvm.script import tir as T @@ -206,4 +207,4 @@ def test_sample_perfect_tile_after_copy(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_set_axis_separator.py b/tests/python/unittest/test_tir_schedule_set_axis_separator.py index d829a3f1b76c..8c3d1e673571 100644 --- a/tests/python/unittest/test_tir_schedule_set_axis_separator.py +++ b/tests/python/unittest/test_tir_schedule_set_axis_separator.py @@ -18,6 +18,7 @@ import sys import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -136,4 +137,4 @@ def test_set_axis_separator_subregion(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_split_fuse.py b/tests/python/unittest/test_tir_schedule_split_fuse.py index b5ab45a505fe..16eef57c4748 100644 --- a/tests/python/unittest/test_tir_schedule_split_fuse.py +++ b/tests/python/unittest/test_tir_schedule_split_fuse.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -524,4 +525,4 @@ def test_fuse_not_affine(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_state.py b/tests/python/unittest/test_tir_schedule_state.py index bc62fa1ba950..db6909a04877 100644 --- a/tests/python/unittest/test_tir_schedule_state.py +++ b/tests/python/unittest/test_tir_schedule_state.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.ir import IRModule from tvm.script import tir as T @@ -351,4 +352,4 @@ def test_replace_ir_module(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_state_cached_flags.py b/tests/python/unittest/test_tir_schedule_state_cached_flags.py index 8b731404f142..1b4c34973f6c 100644 --- a/tests/python/unittest/test_tir_schedule_state_cached_flags.py +++ b/tests/python/unittest/test_tir_schedule_state_cached_flags.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.state import CachedFlags @@ -781,4 +782,4 @@ def test_uncovered_producer_region(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_tensorize.py b/tests/python/unittest/test_tir_schedule_tensorize.py index 65dfa06eb6c1..a97060f01b28 100644 --- a/tests/python/unittest/test_tir_schedule_tensorize.py +++ b/tests/python/unittest/test_tir_schedule_tensorize.py @@ -646,4 +646,4 @@ def fetch_to_shared(block, idx): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_trace.py b/tests/python/unittest/test_tir_schedule_trace.py index 1923eb23af5b..6fc573b1a8c2 100644 --- a/tests/python/unittest/test_tir_schedule_trace.py +++ b/tests/python/unittest/test_tir_schedule_trace.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule import BlockRV, Instruction, InstructionKind, LoopRV, Trace @@ -275,4 +276,4 @@ def test_apply_json_to_schedule_1(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_transform_layout.py b/tests/python/unittest/test_tir_schedule_transform_layout.py index 35dd2fff53f9..9e7cad4d8526 100644 --- a/tests/python/unittest/test_tir_schedule_transform_layout.py +++ b/tests/python/unittest/test_tir_schedule_transform_layout.py @@ -20,6 +20,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.script import tir as T from tvm.tir.schedule.testing import verify_trace_roundtrip @@ -159,4 +160,4 @@ def ref(B: T.Buffer[(8, 8, 16, 16), "float32"], C: T.Buffer[(128, 128), "float32 if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_schedule_utilities.py b/tests/python/unittest/test_tir_schedule_utilities.py index 5ec4a1120923..0d23d3f95211 100644 --- a/tests/python/unittest/test_tir_schedule_utilities.py +++ b/tests/python/unittest/test_tir_schedule_utilities.py @@ -19,6 +19,7 @@ import pytest import tvm +import tvm.testing from tvm import tir from tvm.ir import IRModule @@ -270,4 +271,4 @@ def test_annotate_unannotate_block(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_texture_scope.py b/tests/python/unittest/test_tir_texture_scope.py index 701a1fe77ab1..2af4710751d7 100644 --- a/tests/python/unittest/test_tir_texture_scope.py +++ b/tests/python/unittest/test_tir_texture_scope.py @@ -18,6 +18,7 @@ import pytest import tvm +import tvm.testing from tvm.ir.module import IRModule from tvm import tir from tvm.script import tir as T @@ -59,4 +60,4 @@ def schedule_block(block): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_compact_buffer_region.py b/tests/python/unittest/test_tir_transform_compact_buffer_region.py index 8ad95bd4bc0c..d3491c9172c5 100644 --- a/tests/python/unittest/test_tir_transform_compact_buffer_region.py +++ b/tests/python/unittest/test_tir_transform_compact_buffer_region.py @@ -17,6 +17,7 @@ import pytest import sys import tvm +import tvm.testing from tvm import te from tvm.script import tir as T @@ -740,4 +741,4 @@ def func_with_let_binding(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_inject_software_pipeline.py b/tests/python/unittest/test_tir_transform_inject_software_pipeline.py index ff7e79c02352..50f96d052b14 100644 --- a/tests/python/unittest/test_tir_transform_inject_software_pipeline.py +++ b/tests/python/unittest/test_tir_transform_inject_software_pipeline.py @@ -18,6 +18,7 @@ import sys import tvm +import tvm.testing from tvm import tir, te, TVMError from tvm.script import tir as T @@ -1022,4 +1023,4 @@ def test_error_missing_annotation(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_lower_cross_thread_reduction.py b/tests/python/unittest/test_tir_transform_lower_cross_thread_reduction.py index 2be3bb181150..9b5937ac6efd 100644 --- a/tests/python/unittest/test_tir_transform_lower_cross_thread_reduction.py +++ b/tests/python/unittest/test_tir_transform_lower_cross_thread_reduction.py @@ -18,6 +18,7 @@ import pytest import tvm +import tvm.testing from tvm import te from tvm.script import tir as T @@ -895,4 +896,4 @@ def test_lower_te(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_storage_flatten.py b/tests/python/unittest/test_tir_transform_storage_flatten.py index 44db6181758f..b84b3479fe9a 100644 --- a/tests/python/unittest/test_tir_transform_storage_flatten.py +++ b/tests/python/unittest/test_tir_transform_storage_flatten.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import tvm +import tvm.testing from tvm import te from tvm.driver.build_module import schedule_to_module from tvm.script import tir as T @@ -165,4 +166,4 @@ def test_flatten_tir(): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_storage_rewrite.py b/tests/python/unittest/test_tir_transform_storage_rewrite.py index 083bd9950a51..df147e411f15 100644 --- a/tests/python/unittest/test_tir_transform_storage_rewrite.py +++ b/tests/python/unittest/test_tir_transform_storage_rewrite.py @@ -17,6 +17,7 @@ import sys import pytest import tvm +import tvm.testing from tvm import te from tvm.driver.build_module import schedule_to_module from tvm.script import tir as T @@ -671,4 +672,4 @@ def func_rewritten(A: T.Buffer[(8,), "float32"]) -> None: if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_transform_unify_thread_binding.py b/tests/python/unittest/test_tir_transform_unify_thread_binding.py index 6880aabcd2f7..457c43a76336 100644 --- a/tests/python/unittest/test_tir_transform_unify_thread_binding.py +++ b/tests/python/unittest/test_tir_transform_unify_thread_binding.py @@ -18,6 +18,7 @@ import sys import tvm +import tvm.testing from tvm import te from tvm.script import tir as T @@ -256,4 +257,4 @@ def test_lower_te(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tir_usmp_algo_hill_climb.py b/tests/python/unittest/test_tir_usmp_algo_hill_climb.py index 863b0a566ce3..44b4e6636b6c 100644 --- a/tests/python/unittest/test_tir_usmp_algo_hill_climb.py +++ b/tests/python/unittest/test_tir_usmp_algo_hill_climb.py @@ -18,6 +18,7 @@ import pytest import random import tvm +import tvm.testing from tvm.tir.usmp.utils import BufferInfo, PoolInfo @@ -391,4 +392,4 @@ def run_intervals(intervals): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_transform_layout.py b/tests/python/unittest/test_transform_layout.py index e7d5f125dc68..18b37741765f 100755 --- a/tests/python/unittest/test_transform_layout.py +++ b/tests/python/unittest/test_transform_layout.py @@ -576,4 +576,4 @@ def test_size_one_buffer(shape, transform): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_tvm_testing_features.py b/tests/python/unittest/test_tvm_testing_features.py index c00fc02c4331..5c0e526f0d4d 100644 --- a/tests/python/unittest/test_tvm_testing_features.py +++ b/tests/python/unittest/test_tvm_testing_features.py @@ -291,4 +291,4 @@ def test_uses_deepcopy(self, fixture_with_deepcopy): if __name__ == "__main__": - sys.exit(pytest.main(sys.argv)) + tvm.testing.main() diff --git a/tests/python/unittest/test_tvmscript_error_report.py b/tests/python/unittest/test_tvmscript_error_report.py index 070b5e85f174..c3dfb322118a 100644 --- a/tests/python/unittest/test_tvmscript_error_report.py +++ b/tests/python/unittest/test_tvmscript_error_report.py @@ -664,4 +664,4 @@ def test_illegal_buffer_slice(): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tvmscript_roundtrip.py b/tests/python/unittest/test_tvmscript_roundtrip.py index 948a76216831..d8b9f3b8fbbc 100644 --- a/tests/python/unittest/test_tvmscript_roundtrip.py +++ b/tests/python/unittest/test_tvmscript_roundtrip.py @@ -3335,4 +3335,4 @@ def test_roundtrip(ir_generator): if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main() diff --git a/tests/python/unittest/test_tvmscript_syntax_sugar.py b/tests/python/unittest/test_tvmscript_syntax_sugar.py index b3fe5674a873..0da80d80cf21 100644 --- a/tests/python/unittest/test_tvmscript_syntax_sugar.py +++ b/tests/python/unittest/test_tvmscript_syntax_sugar.py @@ -18,6 +18,7 @@ import sys import pytest +import tvm.testing from tvm.ir import assert_structural_equal from tvm.script import tir as T from tvm.script.parser import from_source @@ -347,4 +348,4 @@ def mma_sync_m16n16k16_desc_manual(a: T.handle, b: T.handle, c: T.handle) -> Non if __name__ == "__main__": - sys.exit(pytest.main([__file__] + sys.argv[1:])) + tvm.testing.main()