From 7f4ef8689075157a5a42dc707d6d1ae55f0567a5 Mon Sep 17 00:00:00 2001 From: Elen Kalda Date: Wed, 12 Jan 2022 18:51:02 +0200 Subject: [PATCH] [microNPU] Enable the codegen tests for 256 mac Arm(R) Ethos(TM)-U65 NPU (#9815) This patch has necessary changes to the Makefile and test infra to run the FVP based codegen tests on a newer NPU variant. --- .../backend/contrib/ethosu/tir_to_cs_translator.py | 7 ++++--- python/tvm/relay/backend/contrib/ethosu/vela_api.py | 1 + tests/python/contrib/test_ethosu/infra.py | 9 +++++++-- tests/python/contrib/test_ethosu/test_codegen.py | 2 +- tests/python/relay/aot/aot_test_utils.py | 1 - tests/python/relay/aot/corstone300.mk | 10 ++++++++-- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py b/python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py index 464a3bd9984fd..77fbc3e8628d6 100644 --- a/python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py +++ b/python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py @@ -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] diff --git a/python/tvm/relay/backend/contrib/ethosu/vela_api.py b/python/tvm/relay/backend/contrib/ethosu/vela_api.py index 9238b162c8fd1..fd915a504d673 100644 --- a/python/tvm/relay/backend/contrib/ethosu/vela_api.py +++ b/python/tvm/relay/backend/contrib/ethosu/vela_api.py @@ -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 diff --git a/tests/python/contrib/test_ethosu/infra.py b/tests/python/contrib/test_ethosu/infra.py index cf447c6a4f38c..96c8433a63848 100644 --- a/tests/python/contrib/test_ethosu/infra.py +++ b/tests/python/contrib/test_ethosu/infra.py @@ -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=""" @@ -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, diff --git a/tests/python/contrib/test_ethosu/test_codegen.py b/tests/python/contrib/test_ethosu/test_codegen.py index f42c06aa83472..23fd74dc486dd 100644 --- a/tests/python/contrib/test_ethosu/test_codegen.py +++ b/tests/python/contrib/test_ethosu/test_codegen.py @@ -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): diff --git a/tests/python/relay/aot/aot_test_utils.py b/tests/python/relay/aot/aot_test_utils.py index 3dfbd765f780c..3f448ca4a7d9c 100644 --- a/tests/python/relay/aot/aot_test_utils.py +++ b/tests/python/relay/aot/aot_test_utils.py @@ -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", diff --git a/tests/python/relay/aot/corstone300.mk b/tests/python/relay/aot/corstone300.mk index 75b99337b15b9..8ff11e29e5e2f 100644 --- a/tests/python/relay/aot/corstone300.mk +++ b/tests/python/relay/aot/corstone300.mk @@ -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 @@ -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: