Skip to content

Cortex-M backend: Minimize scope of cmsis_nn dependency.#20371

Merged
Erik-Lundell merged 2 commits into
pytorch:mainfrom
Erik-Lundell:move-cmsis-check
Jun 18, 2026
Merged

Cortex-M backend: Minimize scope of cmsis_nn dependency.#20371
Erik-Lundell merged 2 commits into
pytorch:mainfrom
Erik-Lundell:move-cmsis-check

Conversation

@Erik-Lundell

@Erik-Lundell Erik-Lundell commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

For Ethos-U flows, you might want to run only the ReplaceQuantNodesPass pass which doesn't require the cmsis_nn dependency. Since the install is currently not trivial, we shouldn't force people to do it when not needed.
Right now, all passes are imported when importing that pass, triggering importing cmsis_nn.

  • Only require cmsis_nn when cmsis_nn functions are used.
  • Do this by wrapping cmsis_nn, taking the chance to add typing.

Tested by running
from executorch.backends.cortex_m.passes import ReplaceQuantNodesPass

Before the patch this triggers an error if cmsis_nn is not installed. After the patch, it doesn't.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani @psiddh @AdrianLundell

For Ethos-U flows, you might want to run only the ReplaceQuantNodesPass
pass which doesn't require the cmsis_nn dependency. Since the install
is currently not trivial, we shouldn't force people to do it when
not needed.
Right now, all passes are imported when importing that pass,
triggering importing cmsis_nn.

- Move dependency check to only trigger when cmsis_nn is imported.
- Do this by wrapping cmsis_nn, taking the chance to add typing.
- Lazy load passes to not require importing all passes.

Tested by running
from executorch.backends.cortex_m.passes import ReplaceQuantNodesPass

Before the patch this triggers an error if cmsis_nn is not installed.
After the patch, it doesn't.

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: Ic674509b09355145cdaa601008ba19074bda0283
@Erik-Lundell Erik-Lundell requested a review from rascani as a code owner June 18, 2026 07:34
@pytorch-bot

pytorch-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20371

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 2 Unrelated Failures

As of commit bfea4e5 with merge base 3707efa (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2026
@Erik-Lundell Erik-Lundell added ciflow/trunk partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm labels Jun 18, 2026
@zingo zingo added the module: microcontrollers For embedded MCUs like Cortex-M, or RTOS like Zephyr, does not track NPU backend like Arm Ethos. label Jun 18, 2026
@Erik-Lundell Erik-Lundell added the release notes: none Do not include this in the release notes label Jun 18, 2026
@Erik-Lundell Erik-Lundell merged commit 1b8ef9d into pytorch:main Jun 18, 2026
485 of 492 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: microcontrollers For embedded MCUs like Cortex-M, or RTOS like Zephyr, does not track NPU backend like Arm Ethos. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants