Skip to content

Commit

Permalink
Merge pull request #2 from apache/main
Browse files Browse the repository at this point in the history
Fork Sync: Update from parent repository
  • Loading branch information
github-actions[bot] authored Jan 13, 2023
2 parents d5f207d + 5878f60 commit 05e74c1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
4 changes: 4 additions & 0 deletions gallery/how_to/work_with_microtvm/install_cmsis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 1 addition & 7 deletions gallery/how_to/work_with_microtvm/micro_aot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@
# 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"))

######################################################################
#
# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_zephyr.rst
#

######################################################################
#
# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_cmsis.rst
#

######################################################################
# Import Python dependencies
# -------------------------------
Expand Down Expand Up @@ -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"),
}

Expand Down
6 changes: 1 addition & 5 deletions gallery/how_to/work_with_microtvm/micro_autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 1 addition & 7 deletions gallery/how_to/work_with_microtvm/micro_tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@
# 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"))

######################################################################
#
# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_zephyr.rst
#

######################################################################
#
# .. include:: ../../../../gallery/how_to/work_with_microtvm/install_cmsis.rst
#

######################################################################
# Import Python dependencies
# -------------------------------
Expand Down Expand Up @@ -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"),
}

Expand Down
10 changes: 6 additions & 4 deletions src/target/parsers/aprofile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ static TargetFeatures GetFeatures(TargetJSON target) {
}

static Array<String> MergeKeys(Optional<Array<String>> existing_keys) {
const String kExtraKey = "arm_cpu";
const Array<String> kExtraKeys = {"arm_cpu", "cpu"};

if (!existing_keys) {
return {kExtraKey};
return kExtraKeys;
}

Array<String> 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;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/target/parsers/aprofile_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ static TargetFeatures ParseTargetWithAttrs(String mcpu, String mtriple, Array<St
TEST(AProfileParser, ParseTargetKeys) {
TargetJSON target = ParseTarget({});
Array<String> keys = Downcast<Array<String>>(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) {
Expand Down

0 comments on commit 05e74c1

Please sign in to comment.