Skip to content

Commit 9c3fbff

Browse files
committed
cleanup
1 parent 42a081b commit 9c3fbff

File tree

13 files changed

+34
-61
lines changed

13 files changed

+34
-61
lines changed

apps/microtvm/cmsisnn/run_demo.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ python3 -m tvm.driver.tvmc compile --target=cmsis-nn,c \
125125
--executor=aot \
126126
--executor-aot-interface-api=c \
127127
--executor-aot-unpacked-api=1 \
128+
--pass-config tir.usmp.enable=1 \
128129
--pass-config tir.usmp.algorithm=hill_climb \
129130
--pass-config tir.disable_storage_rewrite=1 \
130131
--pass-config tir.disable_vectorize=1 ./person_detect.tflite \

apps/microtvm/ethosu/run_demo.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ python3 -m tvm.driver.tvmc compile --target=ethos-u,cmsis-nn,c \
152152
--executor=aot \
153153
--executor-aot-interface-api=c \
154154
--executor-aot-unpacked-api=1 \
155+
--pass-config tir.usmp.enable=1 \
155156
--pass-config tir.usmp.algorithm=hill_climb \
156157
--pass-config tir.disable_storage_rewrite=1 \
157158
--pass-config tir.disable_vectorize=1 ./mobilenet_v2_1.0_224_INT8.tflite --output-format=mlf

src/relay/backend/aot_executor_codegen.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include <string>
4545
#include <vector>
4646

47-
#include "../../target/parsers/mprofile.h"
4847
#include "../../target/source/codegen_source_base.h"
4948
#include "../op/annotation/annotation.h"
5049
#include "../op/call/call.h"

tests/micro/arduino/__init__.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/micro/arduino/test_arduino_error_detection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
from tvm.micro.project_api.server import ServerError
2121

22-
from . import utils
22+
import test_utils
2323
import tvm.testing
2424

2525

2626
@pytest.fixture
2727
def project(board, microtvm_debug, workspace_dir, serial_number):
28-
return utils.make_kws_project(board, microtvm_debug, workspace_dir, serial_number)
28+
return test_utils.make_kws_project(board, microtvm_debug, workspace_dir, serial_number)
2929

3030

3131
def test_blank_project_compiles(workspace_dir, project):

tests/micro/arduino/test_arduino_rpc_server.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"""
2424

2525
import pathlib
26-
import sys
2726
import numpy as np
2827
import onnx
2928
import pytest
@@ -35,7 +34,7 @@
3534
from tvm.relay.testing import byoc
3635
from tvm.relay.backend import Executor, Runtime
3736

38-
from . import utils
37+
import test_utils
3938

4039

4140
def _make_session(
@@ -47,7 +46,7 @@ def _make_session(
4746
serial_number: str = None,
4847
):
4948
project = tvm.micro.generate_project(
50-
str(utils.TEMPLATE_PROJECT_DIR),
49+
str(test_utils.TEMPLATE_PROJECT_DIR),
5150
mod,
5251
workspace_dir / "project",
5352
{
@@ -74,7 +73,7 @@ def _make_sess_from_op(
7473
):
7574
target = tvm.target.target.micro(model)
7675
runtime = Runtime("crt", {"system-lib": True})
77-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
76+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
7877
mod = tvm.build(sched, arg_bufs, target=target, runtime=runtime, name=op_name)
7978

8079
return _make_session(model, arduino_board, workspace_dir, mod, build_config, serial_number)
@@ -103,7 +102,7 @@ def _make_add_sess(model, arduino_board, workspace_dir, build_config, serial_num
103102
def test_compile_runtime(board, microtvm_debug, workspace_dir, serial_number):
104103
"""Test compiling the on-device runtime."""
105104

106-
model = utils.ARDUINO_BOARDS[board]
105+
model = test_utils.ARDUINO_BOARDS[board]
107106
build_config = {"debug": microtvm_debug}
108107

109108
# NOTE: run test in a nested function so cPython will delete arrays before closing the session.
@@ -128,7 +127,7 @@ def test_basic_add(sess):
128127
def test_platform_timer(board, microtvm_debug, workspace_dir, serial_number):
129128
"""Test compiling the on-device runtime."""
130129

131-
model = utils.ARDUINO_BOARDS[board]
130+
model = test_utils.ARDUINO_BOARDS[board]
132131
build_config = {"debug": microtvm_debug}
133132

134133
# NOTE: run test in a nested function so cPython will delete arrays before closing the session.
@@ -157,7 +156,7 @@ def test_basic_add(sess):
157156
@pytest.mark.requires_hardware
158157
def test_relay(board, microtvm_debug, workspace_dir, serial_number):
159158
"""Testing a simple relay graph"""
160-
model = utils.ARDUINO_BOARDS[board]
159+
model = test_utils.ARDUINO_BOARDS[board]
161160
build_config = {"debug": microtvm_debug}
162161

163162
shape = (10,)
@@ -171,7 +170,7 @@ def test_relay(board, microtvm_debug, workspace_dir, serial_number):
171170

172171
target = tvm.target.target.micro(model)
173172
runtime = Runtime("crt", {"system-lib": True})
174-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
173+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
175174
mod = tvm.relay.build(func, target=target, runtime=runtime)
176175

177176
with _make_session(model, board, workspace_dir, mod, build_config, serial_number) as session:
@@ -190,7 +189,7 @@ def test_relay(board, microtvm_debug, workspace_dir, serial_number):
190189
@pytest.mark.requires_hardware
191190
def test_onnx(board, microtvm_debug, workspace_dir, serial_number):
192191
"""Testing a simple ONNX model."""
193-
model = utils.ARDUINO_BOARDS[board]
192+
model = test_utils.ARDUINO_BOARDS[board]
194193
build_config = {"debug": microtvm_debug}
195194

196195
# Load test images.
@@ -212,7 +211,7 @@ def test_onnx(board, microtvm_debug, workspace_dir, serial_number):
212211

213212
target = tvm.target.target.micro(model)
214213
runtime = Runtime("crt", {"system-lib": True})
215-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
214+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
216215
executor = Executor("graph", {"link-params": True})
217216
lowered = relay.build(relay_mod, target, params=params, executor=executor, runtime=runtime)
218217
graph = lowered.get_graph_json()
@@ -253,7 +252,7 @@ def check_result(
253252
TOL = 1e-5
254253
target = tvm.target.target.micro(model)
255254
runtime = Runtime("crt", {"system-lib": True})
256-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
255+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
257256
mod = tvm.relay.build(relay_mod, target=target, runtime=runtime)
258257

259258
with _make_session(
@@ -281,7 +280,7 @@ def check_result(
281280
@pytest.mark.requires_hardware
282281
def test_byoc_microtvm(board, microtvm_debug, workspace_dir, serial_number):
283282
"""This is a simple test case to check BYOC capabilities of microTVM"""
284-
model = utils.ARDUINO_BOARDS[board]
283+
model = test_utils.ARDUINO_BOARDS[board]
285284
build_config = {"debug": microtvm_debug}
286285

287286
x = relay.var("x", shape=(10, 10))
@@ -377,7 +376,7 @@ def _make_add_sess_with_shape(
377376
@pytest.mark.requires_hardware
378377
def test_rpc_large_array(board, microtvm_debug, workspace_dir, shape, serial_number):
379378
"""Test large RPC array transfer."""
380-
model = utils.ARDUINO_BOARDS[board]
379+
model = test_utils.ARDUINO_BOARDS[board]
381380
build_config = {"debug": microtvm_debug}
382381

383382
# NOTE: run test in a nested function so cPython will delete arrays before closing the session.

tests/micro/arduino/test_arduino_workflow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
import pathlib
1919
import re
2020
import shutil
21-
import sys
2221
import pytest
2322

2423
import tvm.testing
2524

26-
from . import utils
25+
import test_utils
2726

2827
"""
2928
This unit test simulates a simple user workflow, where we:
@@ -43,7 +42,7 @@
4342
@pytest.fixture(scope="module")
4443
def workflow_workspace_dir(request):
4544
board = request.config.getoption("--board")
46-
return utils.make_workspace_dir("arduino_workflow", board)
45+
return test_utils.make_workspace_dir("arduino_workflow", board)
4746

4847

4948
@pytest.fixture(scope="module")
@@ -57,7 +56,7 @@ def project_dir(workflow_workspace_dir):
5756
def project(request, microtvm_debug, workflow_workspace_dir):
5857
board = request.config.getoption("--board")
5958
serial_number = request.config.getoption("--serial-number")
60-
return utils.make_kws_project(board, microtvm_debug, workflow_workspace_dir, serial_number)
59+
return test_utils.make_kws_project(board, microtvm_debug, workflow_workspace_dir, serial_number)
6160

6261

6362
def _get_directory_elements(directory):

tests/micro/arduino/utils.py renamed to tests/micro/arduino/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
BOARDS = TEMPLATE_PROJECT_DIR / "boards.json"
3333

34-
PASS_CONFIG = {"tir.disable_vectorize": True}
35-
3634

3735
def arduino_boards() -> dict:
3836
"""Returns a dict mapping board to target model"""
@@ -78,7 +76,7 @@ def make_kws_project(board, microtvm_debug, workspace_dir, serial_number: str):
7876
runtime = Runtime("crt")
7977
executor = Executor("aot", {"unpacked-api": True})
8078

81-
with tvm.transform.PassContext(opt_level=3, config=PASS_CONFIG):
79+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
8280
mod = relay.build(mod, target, runtime=runtime, executor=executor, params=params)
8381

8482
return tvm.micro.generate_project(

tests/micro/zephyr/test_ms_tuning.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@
2424
from tvm import relay
2525
import tvm.micro.testing
2626
from tvm.relay.backend import Executor
27-
from tvm.contrib import graph_executor, utils
27+
from tvm.contrib import graph_executor
2828
from tvm import meta_schedule as ms
2929
from tvm.contrib.micro.meta_schedule.local_builder_micro import get_local_builder_micro
3030
from tvm.contrib.micro.meta_schedule.rpc_runner_micro import get_rpc_runner_micro
3131

32-
from . import utils
33-
3432

3533
def create_relay_module():
3634
data_shape = (1, 3, 16, 16)
@@ -163,7 +161,7 @@ def test_ms_tuning_conv2d(workspace_dir, board, microtvm_debug, use_fvp, serial_
163161
dev = tvm.cpu()
164162
target = tvm.micro.testing.get_target("crt")
165163
with tvm.transform.PassContext(
166-
opt_level=3, config=utils.PASS_CONFIG, disabled_pass=["AlterOpLayout"]
164+
opt_level=3, config={"tir.disable_vectorize": True}, disabled_pass=["AlterOpLayout"]
167165
):
168166
ref_mod = relay.build(
169167
mod,

tests/micro/zephyr/test_zephyr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _make_sess_from_op(
5252
runtime = Runtime("crt", {"system-lib": True})
5353
target = tvm.micro.testing.get_target("zephyr", board)
5454
target = tvm.target.Target(target=target, host=target)
55-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
55+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
5656
mod = tvm.build(sched, arg_bufs, target=target, runtime=runtime, name=op_name)
5757

5858
return _make_session(temp_dir, board, mod, build_config, use_fvp, serial_number)
@@ -209,7 +209,7 @@ def test_relay(workspace_dir, board, microtvm_debug, use_fvp, serial_number):
209209

210210
runtime = Runtime("crt", {"system-lib": True})
211211
target = tvm.micro.testing.get_target("zephyr", board)
212-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
212+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
213213
mod = tvm.relay.build(ir_mod, target=target, runtime=runtime)
214214

215215
with _make_session(workspace_dir, board, mod, build_config, use_fvp, serial_number) as session:
@@ -252,7 +252,7 @@ def test_onnx(workspace_dir, board, microtvm_debug, use_fvp, serial_number):
252252
# the model weights when set using graph_mod.set_input().
253253
# See: https://github.com/apache/tvm/issues/7567
254254
target = tvm.micro.testing.get_target("zephyr", board)
255-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
255+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
256256
executor = Executor("graph", {"link-params": True})
257257
runtime = Runtime("crt", {"system-lib": True})
258258
lowered = relay.build(relay_mod, target, params=params, executor=executor, runtime=runtime)
@@ -293,7 +293,7 @@ def check_result(
293293
TOL = 1e-5
294294
runtime = Runtime("crt", {"system-lib": True})
295295
target = tvm.micro.testing.get_target("zephyr", board)
296-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
296+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
297297
mod = tvm.relay.build(relay_mod, target=target, runtime=runtime)
298298

299299
with _make_session(temp_dir, board, mod, build_config, use_fvp, serial_number) as session:
@@ -454,7 +454,7 @@ def test_autotune_conv2d(workspace_dir, board, microtvm_debug, use_fvp, serial_n
454454
params = {mod["main"].params[1].name_hint: weight_sample}
455455

456456
target = tvm.micro.testing.get_target("zephyr", board)
457-
pass_context = tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG)
457+
pass_context = tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True})
458458
with pass_context:
459459
tasks = tvm.autotvm.task.extract_from_program(mod["main"], {}, target)
460460
assert len(tasks) > 0
@@ -482,7 +482,7 @@ def test_autotune_conv2d(workspace_dir, board, microtvm_debug, use_fvp, serial_n
482482
builder = tvm.autotvm.LocalBuilder(
483483
timeout=timeout,
484484
n_parallel=1,
485-
build_kwargs={"build_option": utils.PASS_CONFIG},
485+
build_kwargs={"build_option": {"tir.disable_vectorize": True}},
486486
do_fork=True,
487487
build_func=tvm.micro.autotvm_build_func,
488488
runtime=runtime,
@@ -580,7 +580,7 @@ def test_schedule_build_with_cmsis_dependency(workspace_dir, board, microtvm_deb
580580

581581
runtime = Runtime("crt", {"system-lib": True})
582582

583-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
583+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
584584
mod = tvm.relay.build(ir_mod, target=target, runtime=runtime)
585585

586586
project_options = {
@@ -633,7 +633,7 @@ def test_debugging_enabled(workspace_dir):
633633
executor = Executor("aot")
634634
target = tvm.micro.testing.get_target("zephyr", board)
635635

636-
with tvm.transform.PassContext(opt_level=3, config=utils.PASS_CONFIG):
636+
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
637637
mod = tvm.relay.build(ir_mod, target=target, runtime=runtime, executor=executor)
638638

639639
project = tvm.micro.generate_project(

0 commit comments

Comments
 (0)