2323"""
2424
2525import pathlib
26- import sys
2726import numpy as np
2827import onnx
2928import pytest
3534from tvm .relay .testing import byoc
3635from tvm .relay .backend import Executor , Runtime
3736
38- from . import utils
37+ import test_utils
3938
4039
4140def _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
103102def 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):
128127def 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
158157def 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
191190def 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
282281def 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
378377def 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.
0 commit comments