Skip to content

Commit bf272de

Browse files
committed
up
1 parent ca4b3c2 commit bf272de

File tree

1 file changed

+1
-101
lines changed

1 file changed

+1
-101
lines changed

docs/source/backends-coreml.md

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ See [PyTorch 2 Export Post Training Quantization](https://pytorch.org/tutorials/
165165

166166
## Runtime integration
167167

168-
To run the model on-device, use the standard ExecuTorch runtime APIs. See [Running on Device](getting-started.md#running-on-device) for more information.
168+
To run the model on-device, use the standard ExecuTorch runtime APIs. See [Running on Device](getting-started.md#running-on-device) for more information, including building the iOS frameworks.
169169

170170
When building from source, pass `-DEXECUTORCH_BUILD_COREML=ON` when configuring the CMake build to compile the CoreML backend.
171171

@@ -186,7 +186,6 @@ target_link_libraries(
186186

187187
No additional steps are necessary to use the backend beyond linking the target. A CoreML-delegated .pte file will automatically run on the registered backend.
188188

189-
190189
---
191190

192191
## Advanced
@@ -199,102 +198,3 @@ python examples/apple/coreml/scripts/extract_coreml_models.py -m /path/to/model.
199198
```
200199

201200
Note that if the ExecuTorch model has graph breaks, there may be multiple extracted *.mlpackage files.
202-
203-
## Other topics
204-
### Runtime:
205-
206-
**Running a Core ML delegated Program**:
207-
1. Build the runner.
208-
```bash
209-
cd executorch
210-
211-
# Builds `coreml_executor_runner`.
212-
./examples/apple/coreml/scripts/build_executor_runner.sh
213-
```
214-
2. Run the CoreML delegated program.
215-
```bash
216-
cd executorch
217-
218-
# Runs the exported mv3 model using the Core ML backend.
219-
./coreml_executor_runner --model_path mv3_coreml_all.pte
220-
```
221-
222-
**Profiling a Core ML delegated Program**:
223-
224-
Note that profiling is supported on [macOS](https://developer.apple.com/macos) >= 14.4.
225-
226-
1. [Optional] Generate an [ETRecord](./etrecord.rst) when exporting your model.
227-
```bash
228-
cd executorch
229-
230-
# Generates `mv3_coreml_all.pte` and `mv3_coreml_etrecord.bin` files.
231-
python3 -m examples.apple.coreml.scripts.export --model_name mv3 --generate_etrecord
232-
```
233-
234-
2. Build the runner.
235-
```bash
236-
# Builds `coreml_executor_runner`.
237-
./examples/apple/coreml/scripts/build_executor_runner.sh
238-
```
239-
3. Run and generate an [ETDump](./etdump.md).
240-
```bash
241-
cd executorch
242-
243-
# Generate the ETDump file.
244-
./coreml_executor_runner --model_path mv3_coreml_all.pte --profile_model --etdump_path etdump.etdp
245-
```
246-
247-
4. Create an instance of the [Inspector API](./model-inspector.rst) by passing in the [ETDump](./etdump.md) you have sourced from the runtime along with the optionally generated [ETRecord](./etrecord.rst) from step 1 or execute the following command in your terminal to display the profiling data table.
248-
```bash
249-
python examples/apple/coreml/scripts/inspector_cli.py --etdump_path etdump.etdp --etrecord_path mv3_coreml.bin
250-
```
251-
252-
253-
## Deploying and running on a device
254-
255-
**Running the Core ML delegated Program in the Demo iOS App**:
256-
1. Please follow the [Export Model](demo-apps-ios.md#models-and-labels) step of the tutorial to bundle the exported [MobileNet V3](https://pytorch.org/vision/main/models/mobilenetv3.html) program. You only need to do the Core ML part.
257-
258-
2. Complete the [Build Runtime and Backends](demo-apps-ios.md#build-runtime-and-backends) section of the tutorial. When building the frameworks you only need the `coreml` option.
259-
260-
3. Complete the [Final Steps](demo-apps-ios.md#final-steps) section of the tutorial to build and run the demo app.
261-
262-
<br>**Running the Core ML delegated Program in your App**
263-
1. Build frameworks, running the following will create a `executorch.xcframework` and `coreml_backend.xcframework` in the `cmake-out` directory.
264-
```bash
265-
cd executorch
266-
./build/build_apple_frameworks.sh --coreml
267-
```
268-
2. Create a new [Xcode project](https://developer.apple.com/documentation/xcode/creating-an-xcode-project-for-an-app#) or open an existing project.
269-
270-
3. Drag the `executorch.xcframework` and `coreml_backend.xcframework` generated from Step 2 to Frameworks.
271-
272-
4. Go to the project's [Build Phases](https://developer.apple.com/documentation/xcode/customizing-the-build-phases-of-a-target) - Link Binaries With Libraries, click the + sign, and add the following frameworks:
273-
```
274-
executorch.xcframework
275-
coreml_backend.xcframework
276-
Accelerate.framework
277-
CoreML.framework
278-
libsqlite3.tbd
279-
```
280-
5. Add the exported program to the [Copy Bundle Phase](https://developer.apple.com/documentation/xcode/customizing-the-build-phases-of-a-target#Copy-files-to-the-finished-product) of your Xcode target.
281-
282-
6. Please follow the [Runtime APIs Tutorial](extension-module.md) to integrate the code for loading an ExecuTorch program.
283-
284-
7. Update the code to load the program from the Application's bundle.
285-
``` objective-c
286-
NSURL *model_url = [NBundle.mainBundle URLForResource:@"mv3_coreml_all" extension:@"pte"];
287-
288-
Result<executorch::extension::FileDataLoader> loader =
289-
executorch::extension::FileDataLoader::from(model_url.path.UTF8String);
290-
```
291-
292-
8. Use [Xcode](https://developer.apple.com/documentation/xcode/building-and-running-an-app#Build-run-and-debug-your-app) to deploy the application on the device.
293-
294-
9. The application can now run the [MobileNet V3](https://pytorch.org/vision/main/models/mobilenetv3.html) model on the Core ML backend.
295-
296-
<br>In this tutorial, you have learned how to lower the [MobileNet V3](https://pytorch.org/vision/main/models/mobilenetv3.html) model to the Core ML backend, deploy, and run it on an Apple device.
297-
298-
## Frequently encountered errors and resolution.
299-
300-
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.

0 commit comments

Comments
 (0)