From 083cbf85baeaa1928b92da4081a111b61de3defe Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Mon, 29 Nov 2021 12:15:38 -0800 Subject: [PATCH] Address @gromero comments --- .../template_project/microtvm_api_server.py | 2 +- tests/micro/arduino/test_utils.py | 1 - tests/micro/common/test_tvmc.py | 61 ++++++++++--------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index ffdbd10afe35b..0f22731896044 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -71,7 +71,7 @@ class BoardAutodetectFailed(Exception): PROJECT_OPTIONS = [ server.ProjectOption( "arduino_board", - required=["generate_project", "build", "flash", "open_transport"], + required=["build", "flash", "open_transport"], choices=list(BOARD_PROPERTIES), type="str", help="Name of the Arduino board to build for.", diff --git a/tests/micro/arduino/test_utils.py b/tests/micro/arduino/test_utils.py index dca1a79743cc7..c107d5b1febfc 100644 --- a/tests/micro/arduino/test_utils.py +++ b/tests/micro/arduino/test_utils.py @@ -58,7 +58,6 @@ def make_workspace_dir(test_name, board): board_workspace = pathlib.Path(str(board_workspace) + f"-{number}") board_workspace.parent.mkdir(exist_ok=True, parents=True) t = tvm.contrib.utils.tempdir(board_workspace) - # time.sleep(200) return t diff --git a/tests/micro/common/test_tvmc.py b/tests/micro/common/test_tvmc.py index fde516b210654..57ea99ee462c1 100644 --- a/tests/micro/common/test_tvmc.py +++ b/tests/micro/common/test_tvmc.py @@ -26,7 +26,6 @@ import tvm from tvm.contrib.download import download_testdata -from tvm.relay.backend import Executor, Runtime from ..zephyr.test_utils import ZEPHYR_BOARDS from ..arduino.test_utils import ARDUINO_BOARDS @@ -36,7 +35,7 @@ MODEL_URL = "https://github.com/tensorflow/tflite-micro/raw/main/tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite" MODEL_FILE = "micro_speech.tflite" - +# TODO(mehrdadh): replace this with _main from tvm.driver.tvmc.main def _run_tvmc(cmd_args: list, *args, **kwargs): """Run a tvmc command and return the results""" cmd_args_list = TVMC_COMMAND + cmd_args @@ -74,8 +73,8 @@ def test_tvmc_model_build_only(board): tar_path = str(temp_dir / "model.tar") project_dir = str(temp_dir / "project") - runtime = str(Runtime("crt")) - executor = str(Executor("graph")) + runtime = "crt" + executor = "graph" cmd_result = _run_tvmc( [ @@ -99,18 +98,19 @@ def test_tvmc_model_build_only(board): ) assert cmd_result == 0, "tvmc failed in step: compile" - cmd_result = _run_tvmc( - [ - "micro", - "create-project", - project_dir, - tar_path, - platform, - "--project-option", - "project_type=host_driven", - f"{platform}_board={board}", - ] - ) + create_project_cmd = [ + "micro", + "create-project", + project_dir, + tar_path, + platform, + "--project-option", + "project_type=host_driven", + ] + if platform == "zephyr": + create_project_cmd.append(f"{platform}_board={board}") + + cmd_result = _run_tvmc(create_project_cmd) assert cmd_result == 0, "tvmc micro failed in step: create-project" cmd_result = _run_tvmc( @@ -129,8 +129,8 @@ def test_tvmc_model_run(board): tar_path = str(temp_dir / "model.tar") project_dir = str(temp_dir / "project") - runtime = str(Runtime("crt")) - executor = str(Executor("graph")) + runtime = "crt" + executor = "graph" cmd_result = _run_tvmc( [ @@ -154,18 +154,19 @@ def test_tvmc_model_run(board): ) assert cmd_result == 0, "tvmc failed in step: compile" - cmd_result = _run_tvmc( - [ - "micro", - "create-project", - project_dir, - tar_path, - platform, - "--project-option", - "project_type=host_driven", - f"{platform}_board={board}", - ] - ) + create_project_cmd = [ + "micro", + "create-project", + project_dir, + tar_path, + platform, + "--project-option", + "project_type=host_driven", + ] + if platform == "zephyr": + create_project_cmd.append(f"{platform}_board={board}") + + cmd_result = _run_tvmc(create_project_cmd) assert cmd_result == 0, "tvmc micro failed in step: create-project" cmd_result = _run_tvmc(