From bd3d93b6a4f7883c89711b9feda44d205f1e3146 Mon Sep 17 00:00:00 2001 From: Nicola Lancellotti Date: Thu, 12 Jan 2023 23:36:05 +0000 Subject: [PATCH 1/2] Remove tutorials CMSIS dependency when not needed (#13762) * Remove tutorials CMSIS dependencies when not needed Change-Id: Ic844422c74855f774b97ea57c6cb6eac2236e29b * Address comments Change-Id: Idbaada0753a9d46cfd94f71fcb30c7f7a8a1d17d --- gallery/how_to/work_with_microtvm/install_cmsis.rst | 4 ++++ gallery/how_to/work_with_microtvm/micro_aot.py | 8 +------- gallery/how_to/work_with_microtvm/micro_autotune.py | 6 +----- gallery/how_to/work_with_microtvm/micro_tflite.py | 8 +------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/gallery/how_to/work_with_microtvm/install_cmsis.rst b/gallery/how_to/work_with_microtvm/install_cmsis.rst index 2f1d2fb1189a5..13286b1b54f60 100644 --- a/gallery/how_to/work_with_microtvm/install_cmsis.rst +++ b/gallery/how_to/work_with_microtvm/install_cmsis.rst @@ -33,3 +33,7 @@ Install CMSIS-NN wget ${CMSIS_URL} -O "${DOWNLOAD_PATH}" tar -xf "${DOWNLOAD_PATH}" -C ${CMSIS_PATH} --strip-components=1 rm ${DOWNLOAD_PATH} + + CMSIS_NN_TAG="v4.0.0" + CMSIS_NN_URL="https://github.com/ARM-software/CMSIS-NN.git" + git clone ${CMSIS_NN_URL} --branch ${CMSIS_NN_TAG} --single-branch ${CMSIS_PATH}/CMSIS-NN diff --git a/gallery/how_to/work_with_microtvm/micro_aot.py b/gallery/how_to/work_with_microtvm/micro_aot.py index 81109b2965ef7..c1b29ba5c5820 100644 --- a/gallery/how_to/work_with_microtvm/micro_aot.py +++ b/gallery/how_to/work_with_microtvm/micro_aot.py @@ -41,7 +41,7 @@ # By default, this tutorial runs on x86 CPU using TVM's C runtime. If you would like # to run on real Zephyr hardware, you must export the `TVM_MICRO_USE_HW` environment # variable. Otherwise (if you are using the C runtime), you can skip installing -# Zephyr and CMSIS-NN. It takes ~20 minutes to install both of them. +# Zephyr. It takes ~20 minutes to install Zephyr. use_physical_hw = bool(os.getenv("TVM_MICRO_USE_HW")) ###################################################################### @@ -49,11 +49,6 @@ # .. include:: ../../../../gallery/how_to/work_with_microtvm/install_zephyr.rst # -###################################################################### -# -# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_cmsis.rst -# - ###################################################################### # Import Python dependencies # ------------------------------- @@ -159,7 +154,6 @@ "board": BOARD, "serial_number": SERIAL, "config_main_stack_size": 4096, - "cmsis_path": os.getenv("CMSIS_PATH", default="/content/cmsis"), "zephyr_base": os.getenv("ZEPHYR_BASE", default="/content/zephyrproject/zephyr"), } diff --git a/gallery/how_to/work_with_microtvm/micro_autotune.py b/gallery/how_to/work_with_microtvm/micro_autotune.py index 9edb9ae75e7fb..9be257a57ac57 100644 --- a/gallery/how_to/work_with_microtvm/micro_autotune.py +++ b/gallery/how_to/work_with_microtvm/micro_autotune.py @@ -33,7 +33,7 @@ # -# You can skip the following two sections (installing Zephyr and CMSIS-NN) if the following flag is False. +# You can skip the following section (installing Zephyr) if the following flag is False. # Installing Zephyr takes ~20 min. import os @@ -44,10 +44,6 @@ # .. include:: ../../../../gallery/how_to/work_with_microtvm/install_zephyr.rst # -###################################################################### -# -# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_cmsis.rst -# ###################################################################### # Import Python dependencies diff --git a/gallery/how_to/work_with_microtvm/micro_tflite.py b/gallery/how_to/work_with_microtvm/micro_tflite.py index 86e5d6b4b1aec..0770d472c9b81 100644 --- a/gallery/how_to/work_with_microtvm/micro_tflite.py +++ b/gallery/how_to/work_with_microtvm/micro_tflite.py @@ -36,7 +36,7 @@ # By default, this tutorial runs on x86 CPU using TVM's C runtime. If you would like # to run on real Zephyr hardware, you must export the `TVM_MICRO_USE_HW` environment # variable. Otherwise (if you are using the C runtime), you can skip installing -# Zephyr and CMSIS-NN. It takes ~20 minutes to install both of them. +# Zephyr. It takes ~20 minutes to install Zephyr. use_physical_hw = bool(os.getenv("TVM_MICRO_USE_HW")) ###################################################################### @@ -44,11 +44,6 @@ # .. include:: ../../../../gallery/how_to/work_with_microtvm/install_zephyr.rst # -###################################################################### -# -# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_cmsis.rst -# - ###################################################################### # Import Python dependencies # ------------------------------- @@ -219,7 +214,6 @@ "board": BOARD, "serial_number": SERIAL, "config_main_stack_size": 4096, - "cmsis_path": os.getenv("CMSIS_PATH", default="/content/cmsis"), "zephyr_base": os.getenv("ZEPHYR_BASE", default="/content/zephyrproject/zephyr"), } From 5878f6090b11dd20c124b322fd76c47a00bbb985 Mon Sep 17 00:00:00 2001 From: AndrewZhaoLuo Date: Thu, 12 Jan 2023 16:12:56 -0800 Subject: [PATCH 2/2] [Target] Make `key=arm_cpu` --> `key=arm_cpu,cpu` on AArch64 (#13775) * arm cpu is cpu * init commit * fix test --- src/target/parsers/aprofile.cc | 10 ++++++---- tests/cpp/target/parsers/aprofile_test.cc | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/target/parsers/aprofile.cc b/src/target/parsers/aprofile.cc index 2fd5fe71e617f..6b0712461026c 100644 --- a/src/target/parsers/aprofile.cc +++ b/src/target/parsers/aprofile.cc @@ -134,15 +134,17 @@ static TargetFeatures GetFeatures(TargetJSON target) { } static Array MergeKeys(Optional> existing_keys) { - const String kExtraKey = "arm_cpu"; + const Array kExtraKeys = {"arm_cpu", "cpu"}; if (!existing_keys) { - return {kExtraKey}; + return kExtraKeys; } Array keys = existing_keys.value(); - if (std::find(keys.begin(), keys.end(), kExtraKey) == keys.end()) { - keys.push_back(kExtraKey); + for (String key : kExtraKeys) { + if (std::find(keys.begin(), keys.end(), key) == keys.end()) { + keys.push_back(key); + } } return keys; } diff --git a/tests/cpp/target/parsers/aprofile_test.cc b/tests/cpp/target/parsers/aprofile_test.cc index 0382e7a84bd7e..ffbc5fd431a71 100644 --- a/tests/cpp/target/parsers/aprofile_test.cc +++ b/tests/cpp/target/parsers/aprofile_test.cc @@ -48,8 +48,9 @@ static TargetFeatures ParseTargetWithAttrs(String mcpu, String mtriple, Array keys = Downcast>(target.at("keys")); - ASSERT_EQ(keys.size(), 1); + ASSERT_EQ(keys.size(), 2); ASSERT_EQ(keys[0], "arm_cpu"); + ASSERT_EQ(keys[1], "cpu"); } TEST(AProfileParser, ParseTargetWithExistingKeys) {