Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMSIS-NN] Support CMSIS NN from new GitHub location #13656

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

NicolaLancellotti
Copy link
Contributor

@NicolaLancellotti NicolaLancellotti commented Dec 23, 2022

CMSIS NN has been moved out of the CMSIS project into a new GitHub project.
This pr adds support for CMSIS NN from this new GitHub location.
Both CMSIS and CMSIS NN are now downloaded in /opt/arm/ethosu/cmsis

@tvm-bot
Copy link
Collaborator

tvm-bot commented Dec 23, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@ashutosh-arm
Copy link
Contributor

Thanks @NicolaLancellotti for this changes. Looks good to me overall. A small request though - is it possible to checkout the repository with the name CMSIS-NN instead of NN under /opt/arm/ethosu/cmsis?

@NicolaLancellotti
Copy link
Contributor Author

Thanks @NicolaLancellotti for this changes. Looks good to me overall. A small request though - is it possible to checkout the repository with the name CMSIS-NN instead of NN under /opt/arm/ethosu/cmsis?

Done.

Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NicolaLancellotti thanks for this PR!
Could you please add this change to docker script installation?
https://github.com/apache/tvm/blob/main/docker/install/ubuntu_install_cmsis.sh

@NicolaLancellotti
Copy link
Contributor Author

I updated the pr with three commits:

  • First, I supported CMSIS NN from the new GitHub location, as previously done.
  • Second, I prevented the definition of the cmsis_path project API option from an environment variable. Before, thanks to the environment variable, the cmsis_path option was always enabled. That was not a problem, but now CMSIS NN uses a new header (arm_acle.h) which is not always present, so we need to explicitly enable CMSIS when we need it.
  • In the end, I re-added support for the old location of CMSIS NN because the docker image is not yet updated, and we need the tests to pass to accept this pr. In this way, tvm will use the new CMSIS NN project when we will update the docker image, but for now, it uses the old one. I'll create a pr that reverts this last commit when the docker image is updated.

Change-Id: I2c39bc671a8a2583f8e271cae98f61f8cabd1ab9
Change-Id: I1585ec3b31626bde5fa5c70224b1c70b48ceeadf
Change-Id: If6237cc6903d03d0e3ff04e849a6812f1980244a
@@ -85,6 +85,9 @@ cmake -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-non
make

# Build NN Library
mkdir ${CMSIS_PATH}/CMSIS-NN/build/ && cd ${CMSIS_PATH}/CMSIS-NN/build/
cmake .. -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DTARGET_CPU=cortex-m55 -DBUILD_CMSIS_NN_FUNCTIONS=YES -DCMSIS_PATH=${CMSIS_PATH}

mkdir ${CMSIS_PATH}/CMSIS/NN/build/ && cd ${CMSIS_PATH}/CMSIS/NN/build/
cmake .. -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DTARGET_CPU=cortex-m55 -DBUILD_CMSIS_NN_FUNCTIONS=YES
make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of the above commands look similar, I hope they are serving two different things. Can you please revisit them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first one builds the new CMSIS-NN, and the second one builds the old CMSIS/NN.
When the docker image will be updated I'll remove support for CMSIS/NN, that is, I''ll revert this commit: ff57097.

@@ -623,7 +624,7 @@ def test_schedule_build_with_cmsis_dependency(workspace_dir, board, microtvm_deb
assert "CMSIS/DSP/Include" in cmake_content
assert "CMSIS/DSP/Include/dsp" in cmake_content
assert "CMSIS/DSP/Include" in cmake_content
assert "CMSIS/NN/Include" in cmake_content
# assert "CMSIS-NN/Include" in cmake_content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If comment is not useful for future, it can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, after the docker image will be updated, we want this assert.

CMSIS_NN_PATH = ${CMSIS_PATH}/CMSIS-NN
else
CMSIS_NN_PATH = ${CMSIS_PATH}/CMSIS/NN
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't simply looking for the directory work if [ -d " ${CMSIS_PATH}/CMSIS-NN" ]; for simplicity - just curious?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want I can check and improve that, but this code will be reverted when the docker image will be updated.

@@ -31,21 +31,27 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(microtvm_autogenerated_project)

if(DEFINED CMSIS_PATH)
if (EXISTS ${CMSIS_PATH}/CMSIS-NN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a temporary fix until we update the docker image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is.

@mehrdadh
Copy link
Member

mehrdadh commented Jan 9, 2023

It will be hard to keep track of all the follow up changes that are required after we update the image. Could you please add comment in all of those places so we can track them?

@NicolaLancellotti
Copy link
Contributor Author

It will be hard to keep track of all the follow up changes that are required after we update the image. Could you please add comment in all of those places so we can track them?

Hi @mehrdadh, thanks for the review.
I wrote the commits in this pr in such a way that it is easy to track the required changes, we just have to revert this commit ff57097 when the image will be updated.

@ashutosh-arm
Copy link
Contributor

After discussing offline about the remaining issues with @NicolaLancellotti, it looks like the support for the old CMSIS-NN location will be removed in future. Overall the changes LGTM! Thanks @NicolaLancellotti for this critical update.

Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mehrdadh mehrdadh merged commit 746fcaa into apache:main Jan 10, 2023
NicolaLancellotti added a commit to NicolaLancellotti/tvm that referenced this pull request Jan 11, 2023
Pr: apache#13656 adds support for the new CMSIS NN project

Change-Id: I28e99fd511b42d9a77ebc6bdc085fc5ffc6b533a
NicolaLancellotti added a commit to NicolaLancellotti/tvm that referenced this pull request Jan 17, 2023
Pr: apache#13656 adds support for the new CMSIS NN project

Change-Id: I28e99fd511b42d9a77ebc6bdc085fc5ffc6b533a
mehrdadh pushed a commit that referenced this pull request Jan 17, 2023
Pr: #13656 adds support for the new CMSIS NN project
After the docker image is updated we can remove support for the old CMSIS NN project.
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
CMSIS NN has been moved out of the CMSIS project into a new GitHub project.
This pr adds support for CMSIS NN from this new GitHub location.
Both CMSIS and CMSIS NN are now downloaded in /opt/arm/ethosu/cmsis

I updated the pr with three commits:
- First, I supported CMSIS NN from the new GitHub location, as previously done.
- Second, I prevented the definition of the `cmsis_path` project API option from an environment variable. Before, thanks to the environment variable, the `cmsis_path` option was always enabled. That was not a problem, but now CMSIS NN uses a new header (`arm_acle.h`) which is not always present, so we need to explicitly enable CMSIS when we need it.
- In the end, I re-added support for the old location of CMSIS NN because the docker image is not yet updated, and we need the tests to pass to accept this pr. In this way, tvm will use the new CMSIS NN project when we will update the docker image, but for now, it uses the old one. I'll create a pr that reverts this last commit when the docker image is updated.
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
Pr: apache#13656 adds support for the new CMSIS NN project
After the docker image is updated we can remove support for the old CMSIS NN project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants