Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
executor_runner/ | H | 25-Apr-2025 | - | 860 | 787 | |
scripts/ | H | 25-Apr-2025 | - | 1,065 | 825 | |
.gitignore | H A D | 25-Apr-2025 | 203 | 20 | 14 | |
README.md | H A D | 25-Apr-2025 | 2.2 KiB | 83 | 61 |
README.md
1# Examples 2 3This directory contains scripts and other helper utilities to illustrate an end-to-end workflow to run a Core ML delegated `torch.nn.module` with the ExecuTorch runtime. 4 5 6## Directory structure 7```bash 8coreml 9├── scripts # Scripts to build the runner. 10├── executor_runner # The runner implementation. 11└── README.md # This file. 12``` 13 14## Using the examples 15 16We will walk through an example model to generate a Core ML delegated binary file from a python `torch.nn.module` then we will use the `coreml_executor_runner` to run the exported binary file. 17 181. Following the setup guide in [Setting Up ExecuTorch](https://pytorch.org/executorch/stable/getting-started-setup) 19you should be able to get the basic development environment for ExecuTorch working. 20 212. Run `install_requirements.sh` to install dependencies required by the **Core ML** backend. 22 23```bash 24cd executorch 25 26./backends/apple/coreml/scripts/install_requirements.sh 27 28``` 29 303. Run the export script to generate a Core ML delegated binary file. 31 32```bash 33cd executorch 34 35# To get a list of example models 36python3 -m examples.portable.scripts.export -h 37 38# Generates add_coreml_all.pte file if successful. 39python3 -m examples.apple.coreml.scripts.export --model_name add 40``` 41 424. Run the binary file using the `coreml_executor_runner`. 43 44```bash 45cd executorch 46 47# Builds the Core ML executor runner. Generates ./coreml_executor_runner if successful. 48./examples/apple/coreml/scripts/build_executor_runner.sh 49 50# Run the delegated model. 51./coreml_executor_runner --model_path add_coreml_all.pte 52``` 53 54## Frequently encountered errors and resolution. 55- The `examples.apple.coreml.scripts.export` could fail if the model is not supported by the Core ML backend. The following models from the examples models list (` python3 -m examples.portable.scripts.export -h`) are currently supported by the Core ML backend. 56 57```text 58add 59add_mul 60dl3 61edsr 62emformer_join 63emformer_predict 64emformer_transcribe 65ic3 66ic4 67linear 68llama2 69llava_encoder 70mobilebert 71mul 72mv2 73mv2_untrained 74mv3 75resnet18 76resnet50 77softmax 78vit 79w2l 80``` 81 82- If you encountered any bugs or issues following this tutorial please file a bug/issue [here](https://github.com/pytorch/executorch/issues) with tag #coreml. 83