From a6dad0139483a8d0091320c905d4fe73120db80b Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Tue, 10 Aug 2021 16:27:43 -0700 Subject: [PATCH] fix microtvm test script --- tests/micro/zephyr/test_zephyr.py | 12 +++--------- tests/micro/zephyr/test_zephyr_aot.py | 14 ++++++-------- tests/scripts/task_python_microtvm.sh | 2 +- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/tests/micro/zephyr/test_zephyr.py b/tests/micro/zephyr/test_zephyr.py index a1a1805d9acf..14e250c3a44e 100644 --- a/tests/micro/zephyr/test_zephyr.py +++ b/tests/micro/zephyr/test_zephyr.py @@ -210,9 +210,7 @@ def test_relay(temp_dir, platform, west_cmd, tvm_debug): with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}): mod = tvm.relay.build(func, target=target) - with _make_session( - temp_dir, zephyr_board, west_cmd, mod, build_config - ) as session: + with _make_session(temp_dir, zephyr_board, west_cmd, mod, build_config) as session: graph_mod = tvm.micro.create_local_graph_executor( mod.get_graph_json(), session.get_system_lib(), session.device ) @@ -255,9 +253,7 @@ def test_onnx(temp_dir, platform, west_cmd, tvm_debug): lowered = relay.build(relay_mod, target, params=params) graph = lowered.get_graph_json() - with _make_session( - temp_dir, zephyr_board, west_cmd, lowered, build_config - ) as session: + with _make_session(temp_dir, zephyr_board, west_cmd, lowered, build_config) as session: graph_mod = tvm.micro.create_local_graph_executor( graph, session.get_system_lib(), session.device ) @@ -284,9 +280,7 @@ def check_result( with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}): mod = tvm.relay.build(relay_mod, target=target) - with _make_session( - temp_dir, zephyr_board, west_cmd, mod, build_config - ) as session: + with _make_session(temp_dir, zephyr_board, west_cmd, mod, build_config) as session: rt_mod = tvm.micro.create_local_graph_executor( mod.get_graph_json(), session.get_system_lib(), session.device ) diff --git a/tests/micro/zephyr/test_zephyr_aot.py b/tests/micro/zephyr/test_zephyr_aot.py index 1d08a3c5f916..695a70f0482c 100644 --- a/tests/micro/zephyr/test_zephyr_aot.py +++ b/tests/micro/zephyr/test_zephyr_aot.py @@ -47,9 +47,7 @@ PLATFORMS = conftest.PLATFORMS -def _build_project( - temp_dir, zephyr_board, west_cmd, mod, build_config, extra_files_tar=None -): +def _build_project(temp_dir, zephyr_board, west_cmd, mod, build_config, extra_files_tar=None): template_project_dir = ( pathlib.Path(__file__).parent / ".." @@ -69,7 +67,7 @@ def _build_project( "extra_files_tar": extra_files_tar, "project_type": "aot_demo", "west_cmd": west_cmd, - "verbose": 0, + "verbose": bool(build_config.get("debug")), "zephyr_board": zephyr_board, }, ) @@ -139,7 +137,7 @@ def _get_message(fd, expr: str): @tvm.testing.requires_micro -def test_tflite(temp_dir, platform, west_cmd, skip_build, tvm_debug): +def test_tflite(temp_dir, platform, west_cmd, tvm_debug): """Testing a TFLite model.""" if platform not in ["host", "mps2_an521", "nrf5340dk", "stm32l4r5zi_nucleo", "zynq_mp_r5"]: @@ -148,7 +146,7 @@ def test_tflite(temp_dir, platform, west_cmd, skip_build, tvm_debug): model, zephyr_board = PLATFORMS[platform] input_shape = (1, 32, 32, 3) output_shape = (1, 10) - build_config = {"skip_build": skip_build, "debug": tvm_debug} + build_config = {"debug": tvm_debug} model_url = "https://github.com/eembc/ulpmark-ml/raw/fc1499c7cc83681a02820d5ddf5d97fe75d4f663/base_models/ic01/ic01_fp32.tflite" model_path = download_testdata(model_url, "ic01_fp32.tflite", module="model") @@ -222,13 +220,13 @@ def test_tflite(temp_dir, platform, west_cmd, skip_build, tvm_debug): @tvm.testing.requires_micro -def test_qemu_make_fail(temp_dir, platform, west_cmd, skip_build, tvm_debug): +def test_qemu_make_fail(temp_dir, platform, west_cmd, tvm_debug): """Testing QEMU make fail.""" if platform not in ["host", "mps2_an521"]: pytest.skip(msg="Only for QEMU targets.") model, zephyr_board = PLATFORMS[platform] - build_config = {"skip_build": skip_build, "debug": tvm_debug} + build_config = {"debug": tvm_debug} shape = (10,) dtype = "float32" diff --git a/tests/scripts/task_python_microtvm.sh b/tests/scripts/task_python_microtvm.sh index aa49d90eaa43..79b1072cc952 100755 --- a/tests/scripts/task_python_microtvm.sh +++ b/tests/scripts/task_python_microtvm.sh @@ -23,5 +23,5 @@ set -x # NOTE(areusch): Adding to diagnose flaky timeouts source tests/scripts/setup-pytest-env.sh make cython3 -run_pytest ctypes python-microtvm-zephyr tests/micro/zephyr --microtvm-platforms=host +run_pytest ctypes python-microtvm-zephyr tests/micro/zephyr --microtvm-platforms=qemu_x86 run_pytest ctypes python-microtvm-zephyr tests/micro/zephyr --microtvm-platforms=mps2_an521