This is a tutorial for setting up the Core ML backend.
-
Follow the instructions described in Setting Up ExecuTorch to set up ExecuTorch environment.
-
Run the example script to validate that the Core ML backend is set up correctly.
cd executorch
# Saves add_coreml_all.pte in the current directory if successful.
python3 -m examples.apple.coreml.scripts.export --model_name add
- You can now integrate the Core ML backend in code.
# Delegate to Core ML backend
delegated_program_manager = edge_program_manager.to_backend(CoreMLPartitioner())
-
Follow the instructions described in Building with CMake to set up CMake build system.
-
Install Xcode.
-
Install Xcode Command Line Tools.
xcode-select --install
- Build Core ML delegate. The following will create
executorch.xcframework
andcoreml_backend.xcframework
in thecmake-out
directory.
cd executorch
./scripts/build_apple_frameworks.sh --coreml
-
Open the project in Xcode, and drag
executorch.xcframework
andcoreml_backend.xcframework
frameworks generated from Step 2 to Frameworks. -
Go to project Target’s Build Phases - Link Binaries With Libraries, click the + sign, and add the following frameworks:
executorch.xcframework
coreml_backend.xcframework
- Go to project Target’s Build Phases - Link Binaries With Libraries, click the + sign, and add the following frameworks.
Accelerate.framework
CoreML.framework
libsqlite3.tbd
- The target could now run a Core ML delegated Program.