Skip to content

PAL File for Arm Zephyr Executor Runner #12348

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

Merged
merged 6 commits into from
Jul 15, 2025
Merged

Conversation

BujSet
Copy link
Contributor

@BujSet BujSet commented Jul 10, 2025

Summary

Platform file for building Zephyr applications that use Executorch as a module. This is a simplified version of the file used in a Zephyr development branch here.

In the future, it may be prudent to have a PAL file for arm bare metal (I imagine this would require a simple splicing of he PAL functions from the arm_executor_runner.cpp file). Leaving that task for a separate PR.

Test plan

Tested against the arm_executor_runner.cpp that is used in the Arm-EthosU tutorial. Was able to successfully build the Arm Executor Runner, and run the simple add model.

Copy link

pytorch-bot bot commented Jul 10, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 2bab70b with merge base a8070ec (image):

NEW FAILURE - The following job has failed:

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

@facebook-github-bot facebook-github-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 Jul 10, 2025
@BujSet BujSet added the module: arm Issues related to arm backend label Jul 10, 2025
@BujSet
Copy link
Contributor Author

BujSet commented Jul 10, 2025

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Jul 10, 2025
@BujSet BujSet self-assigned this Jul 10, 2025
@BujSet BujSet marked this pull request as ready for review July 10, 2025 18:51
@larryliu0820
Copy link
Contributor

Can you change the zephyr preset to use this file instead of minimal or posix?

@BujSet BujSet marked this pull request as draft July 10, 2025 21:05
@BujSet BujSet force-pushed the zephyr_pal_upstream branch from 3ddc5c8 to f816d77 Compare July 10, 2025 21:07
@larryliu0820
Copy link
Contributor

Can you change the zephyr preset to use this file instead of minimal or posix?

For this you will have to change override the option: https://github.com/pytorch/executorch/blob/main/tools/cmake/preset/default.cmake#L38C3-L38C35

@BujSet
Copy link
Contributor Author

BujSet commented Jul 11, 2025

Can you change the zephyr preset to use this file instead of minimal or posix?

Hm, is this what we want for the preset? The PAL requires access to the Zephyr library, so if I set this in the preset, the build-preset test will fail unless we build the entire test with zephyr. Similarly, if I make the change to the preset file where I set:

set(EXECUTORCH_PAL_DEFAULT_FILE_PATH              "${PROJECT_SOURCE_DIR}/runtime/platform/default/arm_zephyr.hpp")

The commands from the original zephyr cmake preset PR will error out. What do you think @larryliu0820?

@BujSet BujSet force-pushed the zephyr_pal_upstream branch from f816d77 to b37e396 Compare July 11, 2025 00:25
@digantdesai
Copy link
Contributor

No CMake changes?

@BujSet
Copy link
Contributor Author

BujSet commented Jul 11, 2025

No CMake changes?

@digantdesai, kind of the same comment as above in response to Mengwei's question about the preset. The problem is that this file can't be built without linking to an existing zephyr library. To avoid adding zephyr as a dependency, I made the PAL a header file instead of a cpp source file so that it never needs to be built, but can be included when Executorch is built as module of zephyr.

@BujSet BujSet force-pushed the zephyr_pal_upstream branch from b37e396 to 6877540 Compare July 11, 2025 14:50
@BujSet BujSet marked this pull request as ready for review July 11, 2025 14:56
@BujSet BujSet force-pushed the zephyr_pal_upstream branch from 6877540 to cbb7a36 Compare July 14, 2025 15:57
@BujSet BujSet force-pushed the zephyr_pal_upstream branch from cbb7a36 to c78ee9b Compare July 15, 2025 17:32
Copy link
Contributor

@larryliu0820 larryliu0820 left a comment

Choose a reason for hiding this comment

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

ok I think this is fine, but I really think we should have a CI job in ExecuTorch that:

  • install zephyr and executorch as a module of it (you can check out a branch of zephyr)
  • compile with arm runner and memory allocator and PAL
  • run a hello world example

So maybe we can have a quick followup PR

@BujSet BujSet merged commit 967e3b9 into pytorch:main Jul 15, 2025
97 of 98 checks passed
lucylq pushed a commit that referenced this pull request Jul 17, 2025
### Summary
Platform file for building Zephyr applications that use Executorch as a
module. This is a simplified version of the file used in a Zephyr
development branch
[here](https://github.com/BujSet/zephyr/blob/executorch-module-integration/samples/modules/executorch/arm/hello_world/src/arm_zephyr_pal.hpp).

In the future, it may be prudent to have a PAL file for arm bare metal
(I imagine this would require a simple splicing of he PAL functions from
the `arm_executor_runner.cpp` file). Leaving that task for a separate
PR.

### Test plan
Tested against the `arm_executor_runner.cpp` that is used in the
[Arm-EthosU
tutorial](https://docs.pytorch.org/executorch/main/tutorial-arm-ethos-u.html).
Was able to successfully build the Arm Executor Runner, and run the
simple add model.
@BujSet BujSet deleted the zephyr_pal_upstream branch July 17, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend release notes: none Do not include this in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants