Skip to content

Commit

Permalink
[Tests] Replace pytest.main with tvm.testing.main (#13717)
Browse files Browse the repository at this point in the history
This ensures that if you want to run a specific test script then at least it's reasonably consistent and as people copy test files they'll use the new function 😸
  • Loading branch information
Mousius authored Jan 7, 2023
1 parent 875296c commit bd37515
Show file tree
Hide file tree
Showing 115 changed files with 116 additions and 123 deletions.
2 changes: 1 addition & 1 deletion tests/micro/stm32/test_code_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,4 @@ def test_mnist():


if __name__ == "__main__":
sys.exit(pytest.main([os.path.dirname(__file__)] + sys.argv[1:]))
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_cublas.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,4 @@ def test_relay_cublas_dense(n, m, k, in_dtype, out_dtype):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ def test_ethosu_binary_elementwise_matcher(


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,4 @@ def test_force_block_config_elementwise(ofm_layout, block_config_str, expected_b


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ def test_ethosu_conv2d_block_config_from_matcher(


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def test_ethosu_depthwise2d_matcher(kernel, stride, dilation, padding, ifm_layou


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def test_ethosu_identity_matcher():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def test_ethosu_inline_matcher():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def test_ethosu_part():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ def test_conv_performance(


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def test_ethosu_pooling_matcher(pool_shape, stride, padding, ifm_layout, ofm_lay


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ def test_ethosu_unary_elementwise_matcher(ofm_shape, ifm_layout, ofm_layout, op_


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/cascader/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ def test_create_diamond_graph(MobileNetv2DiamondTE):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/cascader/test_pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ def _make_plans(num):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/cascader/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ def test_plan_merge(DRAM, SRAM):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@ def test_plan_generator_two_conv2d_with_slice(FLASH, SRAM, TwoConv2DWithSliceGra


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ def test_propagate(propagator, input_stripe_config, output_stripe_config):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ def test_generate_proposals_mobilenetv1_disable_striping(FLASH, SRAM, MobileNetv


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def test_compute_cycles_annotation(SRAM, FLASH, TwoConv2DTE):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ def test_count_stripes_sliding_window(stripe_config, expected_stripe_counts):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ def test_get_recompute_buffer(DRAM):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_attr_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def test_compiler_attr_default():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
5 changes: 1 addition & 4 deletions tests/python/contrib/test_ethosu/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,4 @@ def fully_connected(x):


if __name__ == "__main__":
import sys
import pytest

sys.exit(pytest.main([__file__] + sys.argv[1:]))
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ def test_lower_to_tir_arg_count(relay_function, arg_count):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -679,4 +679,4 @@ def main(placeholder: T.Buffer[97156, "int8"], placeholder_encoded: T.Buffer[208


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_create_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ def main(placeholder1: T.Buffer[(100,), "int8"], placeholder2: T.Buffer[(100,),


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_encode_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,4 @@ def get_graph():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_extract_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ def _expected():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_layout_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,4 @@ def get_graph():


if __name__ == "__main__":
pytest.main([__file__] + sys.argv[1:])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_legalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2807,4 +2807,4 @@ def representative_dataset():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_lookup_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ def test_random_lut(accel_type):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_lower_to_te.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ def test_ethosu_conv2d():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ def test_networks_with_usmp_and_cascader_with_striping(accel_type, model_url, wo


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,4 @@ def create_external_func1(mod_, compiler_name, symbol_name):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def _get_func():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,4 @@ def _visit(stmt):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_replace_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,4 +818,4 @@ def _get_func():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_replace_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ def _get_func():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_replace_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ def _visit(stmt):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_replace_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,4 @@ def _visit(stmt):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ def _visit(stmt):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_rolling_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def _cascader(cached_func, const_dict, sch):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ def test_copy_constants_fully_connected_weights():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -1499,4 +1499,4 @@ def populate_ethosu_binary_elementwise_calls(stmt):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,4 @@ def test_ethosu_unary_elementwise_invalid_dtype():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_vela_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,4 @@ def verify(test_vec, mock_enc_w):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_libtorch_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ def script_fn(x, y):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/contrib/test_nnpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ def verify(target="llvm", algorithm=nnpack.ConvolutionAlgorithm.AUTO, with_bias=


if __name__ == "__main__":
pytest.main()
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,4 @@ def expected():
if sys.platform == "win32":
print("Skip test on Windows for now")
sys.exit(0)
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ def test_extern_vitis_ai_resnet18(dpu_target):
if sys.platform == "win32":
print("Skip test on Windows for now")
sys.exit(0)
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/driver/tvmc/test_pass_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def test_parse_pass_list_str():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/frontend/mxnet/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2363,4 +2363,4 @@ def test_forward_split_v2(


if __name__ == "__main__":
pytest.main(["test_forward.py"])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/frontend/paddlepaddle/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,4 +1682,4 @@ def forward(self, inputs, prev_h):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -5835,4 +5835,4 @@ def test_forward_dense_bincount():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,4 @@ def func(self, x):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ def call(self, inputs):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
3 changes: 1 addition & 2 deletions tests/python/integration/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
"""Test scheduling of reduction operations."""
import pytest
import numpy as np

import tvm
Expand Down Expand Up @@ -675,4 +674,4 @@ def check_store_dst_remapped(op):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
4 changes: 1 addition & 3 deletions tests/python/integration/test_winograd_nnpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,4 @@ def test_conv2d_nchw():


if __name__ == "__main__":
import pytest

pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/relay/test_adt.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,4 +821,4 @@ def test_iterate():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ def test_higher_order_nested():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ def expected_4():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/relay/test_analysis_extract_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ def test_extract_resnet():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/relay/test_auto_scheduler_task_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ def counting_unique_hash(str_dag):


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
2 changes: 1 addition & 1 deletion tests/python/relay/test_backend_graph_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,4 @@ def test_benchmark_end_to_end_rpc():


if __name__ == "__main__":
pytest.main([__file__])
tvm.testing.main()
Loading

0 comments on commit bd37515

Please sign in to comment.