Skip to content

Commit

Permalink
[microNPU] Enable the codegen tests for 256 mac Arm(R) Ethos(TM)-U65 …
Browse files Browse the repository at this point in the history
…NPU (apache#9815)

This patch has necessary changes to the Makefile and test
infra to run the FVP based codegen tests on a newer NPU variant.
  • Loading branch information
ekalda authored and Raghav-Chakravarthy committed Jan 28, 2022
1 parent fded004 commit 7f4ef86
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ def __init__(self, total_shram_banks):

def get_accelerator_arch_config(accel_type):
accel_config_str_map = {
"ethos-u55-256": AcceleratorArchConfig(48),
"ethos-u55-128": AcceleratorArchConfig(24),
"ethos-u55-64": AcceleratorArchConfig(16),
"ethos-u55-32": AcceleratorArchConfig(16),
"ethos-u55-64": AcceleratorArchConfig(16),
"ethos-u55-128": AcceleratorArchConfig(24),
"ethos-u55-256": AcceleratorArchConfig(48),
"ethos-u65-256": AcceleratorArchConfig(48),
}
return accel_config_str_map[accel_type]

Expand Down
1 change: 1 addition & 0 deletions python/tvm/relay/backend/contrib/ethosu/vela_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def get_accelerator_config() -> vapi.NpuAccelerator:
"ethos-u55-128": vapi.NpuAccelerator.Ethos_U55_128,
"ethos-u55-64": vapi.NpuAccelerator.Ethos_U55_64,
"ethos-u55-32": vapi.NpuAccelerator.Ethos_U55_32,
"ethos-u65-256": vapi.NpuAccelerator.Ethos_U65_256,
}
compiler_attrs = tvm.get_global_func("relay.ext.ethos-u.get_compiler_attrs")()
accel_config_str = compiler_attrs.accelerator_config
Expand Down
9 changes: 7 additions & 2 deletions tests/python/contrib/test_ethosu/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def deserialize_command_stream(blob):
def create_test_runner(accel="ethos-u55-256"):
file_dir = os.path.dirname(os.path.abspath(__file__))
test_root = os.path.join(file_dir, "reference_system")
ethosu_macs = accel[accel.rfind("-") + 1 :]
_, ethosu_variant, ethosu_macs = accel.split("-")
ethosu_variant = ethosu_variant.upper()
return AOTTestRunner(
makefile="corstone300",
prologue="""
Expand All @@ -205,7 +206,11 @@ def create_test_runner(accel="ethos-u55-256"):
ethosu_release_driver(ethos_u);
""",
includes=["uart.h", "ethosu_55.h", "ethosu_mod.h", "hard_fault.h"],
parameters={"ETHOSU_TEST_ROOT": test_root, "NPU_VARIANT": ethosu_macs},
parameters={
"ETHOSU_TEST_ROOT": test_root,
"NPU_MACS": ethosu_macs,
"NPU_VARIANT": ethosu_variant,
},
pass_config={
"relay.ext.ethos-u.options": {
"accelerator_config": accel,
Expand Down
2 changes: 1 addition & 1 deletion tests/python/contrib/test_ethosu/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from . import infra


ACCEL_TYPES = ["ethos-u55-256", "ethos-u55-128", "ethos-u55-64", "ethos-u55-32"]
ACCEL_TYPES = ["ethos-u55-256", "ethos-u55-128", "ethos-u55-64", "ethos-u55-32", "ethos-u65-256"]


def infer_type_function_pass(func):
Expand Down
1 change: 0 additions & 1 deletion tests/python/relay/aot/aot_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ class AOTTestRunner(NamedTuple):
uart_init();
""",
includes=["uart.h"],
parameters={"NPU_VARIANT": "256"},
pass_config={
"relay.ext.cmsisnn.options": {
"mcpu": "cortex-m55",
Expand Down
10 changes: 8 additions & 2 deletions tests/python/relay/aot/corstone300.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ CRT_ROOT ?= ${TVM_ROOT}/build/standalone_crt
ifeq ($(shell ls -lhd $(CRT_ROOT)),)
$(error "CRT not found. Ensure you have built the standalone_crt target and try again")
endif

FVP_DIR ?= /opt/arm/FVP_Corstone_SSE-300_Ethos-U55/models/Linux64_GCC-6.4/

NPU_MACS ?= 256
NPU_VARIANT ?= U55

MODEL = FVP_Corstone_SSE-300_Ethos-$(NPU_VARIANT)

ARM_CPU=ARMCM55
DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
ETHOSU_PATH=/opt/arm/ethosu
Expand Down Expand Up @@ -118,12 +124,12 @@ cleanall:
$(QUIET)rm -rf $(build_dir)

run: $(build_dir)/aot_test_runner
$(FVP_DIR)/FVP_Corstone_SSE-300_Ethos-U55 -C cpu0.CFGDTCMSZ=15 \
$(FVP_DIR)/$(MODEL) -C cpu0.CFGDTCMSZ=15 \
-C cpu0.CFGITCMSZ=15 -C mps3_board.uart0.out_file=\"-\" -C mps3_board.uart0.shutdown_tag=\"EXITTHESIM\" \
-C mps3_board.visualisation.disable-visualisation=1 -C mps3_board.telnetterminal0.start_telnet=0 \
-C mps3_board.telnetterminal1.start_telnet=0 -C mps3_board.telnetterminal2.start_telnet=0 -C mps3_board.telnetterminal5.start_telnet=0 \
-C ethosu.extra_args="--fast" \
-C ethosu.num_macs=$(NPU_VARIANT) $(build_dir)/aot_test_runner
-C ethosu.num_macs=$(NPU_MACS) $(build_dir)/aot_test_runner

.SUFFIXES:

Expand Down

0 comments on commit 7f4ef86

Please sign in to comment.