Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions backends/cortex_m/test/misc/test_cmsis_pybind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2026 Arm Limited and/or its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import importlib

import pytest


def _import_cmsis_nn():
try:
return importlib.import_module("cmsis_nn")
except Exception as exc:
pytest.fail(f"Failed to resolve cmsis_nn: {exc}")


def test_cmsis_nn_convolve_wrapper_buffer_size() -> None:
cmsis_nn = _import_cmsis_nn()

buf_size = cmsis_nn.convolve_wrapper_buffer_size(
cmsis_nn.Backend.MVE,
cmsis_nn.DataType.A8W8,
input_nhwc=[1, 8, 8, 16],
filter_nhwc=[8, 3, 3, 16],
output_nhwc=[1, 6, 6, 8],
padding_hw=[0, 0],
stride_hw=[1, 1],
dilation_hw=[1, 1],
)

assert buf_size == 576
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ dependencies=[
"scikit-learn==1.7.1",
"hydra-core>=1.3.0",
"omegaconf>=2.3.0",
"cmsis_nn @ git+https://github.com/ARM-software/CMSIS-NN.git@ba16fde665262d2ca3cc5074e1b4894461e06a2f",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rather than a project wide dependency, I think we should move this to a cortex-m specific requirements file, similar to how we have backends/arm/requirements-arm-ethos-u.txt. We'll probably need to update the cortex-m documentation to reference this extra step.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The issue here is that this will be required for AOT, so requiring something like that will either break the Cortex-M backend for pip installation completely, or at least disable the buffer planning functionality. My other proposal is to add it as an optional dependency: pip install executorch[cortex_m]. Or, thirdly, built it into the executorch wheel. WDYT?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rascani we have the same thing going on for the TOSA arm-backends now when all tools needed to AOT is pip installable (is about a week ago) and we have an old wish from @digantdesai (and also from us/Arm) to make it more part of the executorch pip install process and easier to use. So whatever we decide/do here we will probably do the same for Ethos-U/VGF backends soonish. (before 1.3 ).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There is a slight difference in that tosa-tools is available from pypi while cmsis_nn needs building. But my original point still stands imo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I lean towards the optional dependency approach (pip install executorch[cortex_m]).

Additionally, we should ensure we keep the SHA in sync with the SHA in CMakeLists.txt that is used for fetching the source.

I think it would also be a good idea to publish a pip package for this.

Copy link
Copy Markdown
Collaborator

@zingo zingo Apr 24, 2026

Choose a reason for hiding this comment

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

@digantdesai would this be a good solution for Arm (and other) backends also.
e.g.
pip install executorch[cortex_m]
pip install executorch[ethos_u]
pip install executorch[vgf]
pip install executorch[nxp]
pip install executorch[qcom]
...
We will probably think about our names a bit, maybe we end up with a common for ethos_u & vgf like tosa_backend or arm_backends there are a lot of common deps but I also think the devs in most cases not overlapping and 2 packages with clear names might be easier to understand, lets see. Any preferences are welcome as a discussion.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree, I will push an updated PR proposing this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Doing this here #19149 which the cmsis_nn dependency can then build on. Closing this PR.

]

[project.optional-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ pytest<9.0
pytest-xdist
pytest-rerunfailures==15.1
pytest-json-report

pybind11>=2.10 # Required to build cmsis_nn pybindings.
scikit-build-core>=0.7 # Required to build cmsis_nn pybindings.
Loading