• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Setting up Core ML backend
2
3This is a tutorial for setting up the Core ML backend.
4
5## AOT Setup
6
71. Follow the instructions described in [Setting Up ExecuTorch](/docs/source/getting-started-setup.md) to set up ExecuTorch environment.
8
92. Run `install_requirements.sh` to install dependencies required by the **Core ML** backend.
10
11```
12cd executorch
13
14./backends/apple/coreml/scripts/install_requirements.sh
15
16```
17
183. Run the example script to validate that the **Core ML** backend is set up correctly.
19
20```
21cd executorch
22
23# Saves add_coreml_all.pte in the current directory if successful.
24
25python3 -m examples.apple.coreml.scripts.export --model_name add
26
27```
28
294. You can now integrate the **Core ML** backend in code.
30
31```python
32# Delegate to Core ML backend
33delegated_program_manager = edge_program_manager.to_backend(CoreMLPartitioner())
34```
35
36
37## Integrating Core ML delegate into runtime.
38
391. Follow the instructions described in [Building with CMake](/docs/source/runtime-build-and-cross-compilation.md#building-with-cmake) to set up CMake build system.
40
412. Install [Xcode](https://developer.apple.com/xcode/).
42
433. Install Xcode Command Line Tools.
44
45```bash
46xcode-select --install
47```
48
494. Build **Core ML** delegate. The following will create `executorch.xcframework` and `coreml_backend.xcframework` in the `cmake-out` directory.
50
51```bash
52cd executorch
53./build/build_apple_frameworks.sh --coreml
54```
555. Open the project in Xcode, and drag `executorch.xcframework` and `coreml_backend.xcframework` frameworks generated from Step 2 to Frameworks.
56
576. Go to project Target’s Build Phases -  Link Binaries With Libraries, click the + sign, and add the following frameworks:
58
59```
60executorch.xcframework
61coreml_backend.xcframework
62```
63
645. Go to project Target’s Build Phases -  Link Binaries With Libraries, click the + sign, and add the following frameworks.
65```
66Accelerate.framework
67CoreML.framework
68libsqlite3.tbd
69```
70
716. The target could now run a **Core ML** delegated **Program**.
72