-
Notifications
You must be signed in to change notification settings - Fork 608
Create a README for build presets #11548
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# ExecuTorch Build Presets | ||
|
||
Build presets are a collection of cmake arguments that configure flavors of ExecuTorch libraries. Build presets are intended to help answer questions like: | ||
|
||
- "How do I build the ET library used in the pip wheel?" → use [pybind.cmake](./pybind.cmake) | ||
- "How do I build the iOS library?" → use [ios.cmake](./ios.cmake) | ||
- "How do I build what's required to run an LLM?" → use [llm.cmake](./llm.cmake) | ||
|
||
## Why? | ||
|
||
See: https://github.com/pytorch/executorch/discussions/10661. tl;dr instead of turning on multiple opaque/unknown flags, you can reduce it to: | ||
|
||
```bash | ||
$ cmake --preset macos | ||
$ cmake --build cmake-out -j100 --target executor_runner | ||
``` | ||
|
||
## Working with Presets | ||
|
||
> [!TIP] | ||
> Configurable presets options and their default values are stored in [default.cmake](./default.cmake). | ||
|
||
### Within ExecuTorch | ||
|
||
If you're developing ExecuTorch directly, you can use the `cmake --preset` command: | ||
|
||
```bash | ||
# List all the presets buildable on your machine | ||
$ cmake --list-presets | ||
|
||
# Build a preset | ||
$ cmake --preset llm | ||
|
||
# Build a preset with one-off configuration change | ||
$ cmake -DEXECUTORCH_BUILD_MPS=OFF --preset llm | ||
``` | ||
|
||
The cmake presets roughly map to the ExecuTorch presets and are explicitly listed in [CMakePresets.json](../../../CMakePresets.json). Note that you are encouraged to rely on presets when build locally and adding build/tests in CI — CI should do what a developer would do and nothing more! | ||
|
||
### Including ExecuTorch as Third-party Library | ||
|
||
#### Choose a built-in preset | ||
|
||
You can include ExecuTorch like any other cmake project in your project: | ||
```cmake | ||
add_subdirectory(executorch) | ||
``` | ||
However, note that since a preset isn't specified, it will use the [default](./default.cmake) options. This likely not what you want — you likely want to use a preset. Check for presets available in [tools/cmake/preset](.) and explicitly choose which preset to use: | ||
|
||
```cmake | ||
set(EXECUTORCH_BUILD_PRESET_FILE executorch/tools/cmake/preset/llm.cmake) | ||
add_subdirectory(executorch) | ||
``` | ||
|
||
Even when using a preset, you can explicitly override specific preset configurations: | ||
|
||
```cmake | ||
set(EXECUTORCH_BUILD_PRESET_FILE executorch/tools/cmake/preset/llm.cmake) | ||
|
||
# Although llm.cmake might have turned on `EXECUTORCH_BUILD_MPS`, you can turn if off | ||
set(EXECUTORCH_BUILD_MPS OFF) | ||
|
||
add_subdirectory(executorch) | ||
``` | ||
|
||
#### Creating your own preset | ||
|
||
Preset files are just cmake files that turn on/off ExecuTorch configs. For example if we want to build the runner with a CoreML backend, create your cmake preset file (i.e. `my_projects_custom_preset.cmake`): | ||
|
||
```cmake | ||
# File: my_projects_custom_preset.cmake | ||
|
||
set_overridable_option(EXECUTORCH_BUILD_COREML ON) | ||
set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) | ||
``` | ||
|
||
We use `set_overridable_option` so that it allows the option to be overriden via the command line using `-D`. Feel free to use the standard `set(...)` function to prevent overriding options. | ||
|
||
Once the preset is created, set `EXECUTORCH_BUILD_PRESET_FILE` before adding ExecuTorch: | ||
|
||
```cmake | ||
set(EXECUTORCH_BUILD_PRESET_FILE my_projects_custom_preset.cmake) | ||
add_subdirectory(executorch) | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.