Skip to content

Commit

Permalink
revert arm_cpu strategy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadh committed May 19, 2022
1 parent 8828561 commit 6fe730c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
13 changes: 5 additions & 8 deletions python/tvm/relay/op/strategy/arm_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,11 @@ def conv2d_strategy_arm_cpu(attrs, inputs, out_type, target):
)
elif layout == "NHWC":
if isa.has_dsp_support and kernel_layout == "HWOI":
# TODO(mehrdadh): Only integer type due to
# https://github.com/apache/tvm/issues/11351
if data.dtype in ["int8", "int16"] and out_dtype == "int32":
strategy.add_implementation(
wrap_compute_conv2d(topi.arm_cpu.conv2d_nhwc_dsp),
wrap_topi_schedule(topi.arm_cpu.schedule_conv2d_nhwc_dsp),
name="conv2d_nhwc_dsp.arm_cpu",
)
strategy.add_implementation(
wrap_compute_conv2d(topi.arm_cpu.conv2d_nhwc_dsp),
wrap_topi_schedule(topi.arm_cpu.schedule_conv2d_nhwc_dsp),
name="conv2d_nhwc_dsp.arm_cpu",
)
elif kernel_layout == "HWIO":
is_aarch64 = topi.arm_cpu.arm_utils.is_aarch64_arm()
has_dot_prod = topi.arm_cpu.arm_utils.is_dotprod_available()
Expand Down
15 changes: 15 additions & 0 deletions tests/micro/zephyr/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@ def temp_dir(board, tvm_debug):
keep_for_debug = tvm_debug if tvm_debug else None
test_temp_dir = tempdir(custom_path=board_workspace, keep_for_debug=keep_for_debug)
return test_temp_dir


@pytest.fixture(autouse=True)
def skip_by_board(request, board):
"""Skip test if board is in the list."""
if request.node.get_closest_marker("skip_boards"):
if board in request.node.get_closest_marker("skip_boards").args[0]:
pytest.skip("skipped on this board: {}".format(board))


def pytest_configure(config):
config.addinivalue_line(
"markers",
"skip_by_board(board): skip test for the given board",
)
14 changes: 13 additions & 1 deletion tests/micro/zephyr/test_zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from tvm.relay.testing import byoc
from tvm.contrib import utils
from tvm.micro.testing import check_tune_log
from tvm.target import arm_isa

import test_utils

Expand Down Expand Up @@ -87,6 +88,7 @@ def _make_add_sess(temp_dir, model, zephyr_board, west_cmd, build_config, dtype=

# The same test code can be executed on both the QEMU simulation and on real hardware.
@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_add_uint(temp_dir, board, west_cmd, tvm_debug):
"""Test compiling the on-device runtime."""

Expand All @@ -112,6 +114,7 @@ def test_basic_add(sess):

# The same test code can be executed on both the QEMU simulation and on real hardware.
@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_add_float(temp_dir, board, west_cmd, tvm_debug):
"""Test compiling the on-device runtime."""
model = test_utils.ZEPHYR_BOARDS[board]
Expand All @@ -138,6 +141,7 @@ def test_basic_add(sess):


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_platform_timer(temp_dir, board, west_cmd, tvm_debug):
"""Test compiling the on-device runtime."""

Expand Down Expand Up @@ -167,6 +171,7 @@ def test_basic_add(sess):


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_relay(temp_dir, board, west_cmd, tvm_debug):
"""Testing a simple relay graph"""
model = test_utils.ZEPHYR_BOARDS[board]
Expand Down Expand Up @@ -199,6 +204,7 @@ def test_relay(temp_dir, board, west_cmd, tvm_debug):


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_onnx(temp_dir, board, west_cmd, tvm_debug):
"""Testing a simple ONNX model."""
model = test_utils.ZEPHYR_BOARDS[board]
Expand Down Expand Up @@ -279,6 +285,7 @@ def check_result(


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_byoc_microtvm(temp_dir, board, west_cmd, tvm_debug):
"""This is a simple test case to check BYOC capabilities of microTVM"""
model = test_utils.ZEPHYR_BOARDS[board]
Expand Down Expand Up @@ -359,6 +366,7 @@ def _make_add_sess_with_shape(temp_dir, model, zephyr_board, west_cmd, shape, bu
],
)
@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_rpc_large_array(temp_dir, board, west_cmd, tvm_debug, shape):
"""Test large RPC array transfer."""
model = test_utils.ZEPHYR_BOARDS[board]
Expand Down Expand Up @@ -511,6 +519,11 @@ def test_schedule_build_with_cmsis_dependency(temp_dir, board, west_cmd, tvm_deb
"""
model = test_utils.ZEPHYR_BOARDS[board]
build_config = {"debug": tvm_debug}
target = tvm.target.target.micro(model, options=["-keys=arm_cpu,cpu"])

isa = arm_isa.IsaAnalyzer(target)
if not isa.has_dsp_support:
pytest.skip(f"ISA does not support DSP. target: {target}")

# Create a Relay conv2d
data_shape = (1, 16, 16, 3)
Expand All @@ -530,7 +543,6 @@ def test_schedule_build_with_cmsis_dependency(temp_dir, board, west_cmd, tvm_deb
ir_mod = tvm.IRModule.from_expr(func)

runtime = Runtime("crt", {"system-lib": True})
target = tvm.target.target.micro(model, options=["-keys=arm_cpu,cpu"])

with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
mod = tvm.relay.build(ir_mod, target=target, runtime=runtime)
Expand Down
2 changes: 2 additions & 0 deletions tests/micro/zephyr/test_zephyr_aot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_tflite(temp_dir, board, west_cmd, tvm_debug):
"""Testing a TFLite model."""
model = test_utils.ZEPHYR_BOARDS[board]
Expand Down Expand Up @@ -94,6 +95,7 @@ def test_tflite(temp_dir, board, west_cmd, tvm_debug):


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_qemu_make_fail(temp_dir, board, west_cmd, tvm_debug):
"""Testing QEMU make fail."""
if board not in ["qemu_x86", "mps2_an521", "mps3_an547"]:
Expand Down
1 change: 1 addition & 0 deletions tests/micro/zephyr/test_zephyr_armv7m.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def _apply_desired_layout_no_simd(relay_mod):


@tvm.testing.requires_micro
@pytest.mark.skip_boards(["mps2_an521"])
def test_armv7m_intrinsic(temp_dir, board, west_cmd, tvm_debug):
"""Testing a ARM v7m SIMD extension."""

Expand Down
1 change: 1 addition & 0 deletions tests/scripts/task_python_microtvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ make cython3
run_pytest ctypes python-microtvm-zephyr-qemu_x86 tests/micro/zephyr --zephyr-board=qemu_x86
run_pytest ctypes python-microtvm-zephyr-qemu_riscv32 tests/micro/zephyr --zephyr-board=qemu_riscv32
run_pytest ctypes python-microtvm-zephyr-qemu_riscv64 tests/micro/zephyr --zephyr-board=qemu_riscv64
run_pytest ctypes python-microtvm-zephyr-mps2_an521 tests/micro/zephyr --zephyr-board=mps2_an521

# Arduino
run_pytest ctypes python-microtvm-arduino apps/microtvm/arduino/template_project/tests
Expand Down

0 comments on commit 6fe730c

Please sign in to comment.