From 6da65b8e921b442099033fdd3f56e1d8e334ad33 Mon Sep 17 00:00:00 2001 From: Riandy Riandy Date: Wed, 18 Sep 2024 09:12:21 -0700 Subject: [PATCH] Improve iOS demo app readme (#5453) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/5453 - Add instructions on how to clear package dependencies cache Reviewed By: shoumikhin Differential Revision: D62909056 --- examples/demo-apps/apple_ios/LLaMA/README.md | 30 +++++++++++++++++-- .../LLaMA/docs/delegates/mps_README.md | 19 ++++++++++-- .../LLaMA/docs/delegates/xnnpack_README.md | 19 ++++++++++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/examples/demo-apps/apple_ios/LLaMA/README.md b/examples/demo-apps/apple_ios/LLaMA/README.md index 7e9fc59339e..af91239124e 100644 --- a/examples/demo-apps/apple_ios/LLaMA/README.md +++ b/examples/demo-apps/apple_ios/LLaMA/README.md @@ -33,17 +33,41 @@ First it’s important to note that currently ExecuTorch provides support across ## How to Use the App This section will provide the main steps to use the app, along with a code snippet of the ExecuTorch API. -```{note} +### Swift Package Manager + ExecuTorch runtime is distributed as a Swift package providing some .xcframework as prebuilt binary targets. Xcode will download and cache the package on the first run, which will take some time. + +Note: If you're running into any issues related to package dependencies, quit Xcode entirely, delete the whole executorch repo, clean the caches by running the command below in terminal and clone the repo again. + +```rm -rf \ + ~/Library/org.swift.swiftpm \ + ~/Library/Caches/org.swift.swiftpm \ + ~/Library/Caches/com.apple.dt.Xcode \ + ~/Library/Developer/Xcode/DerivedData ``` +Link your binary with the ExecuTorch runtime and any backends or kernels used by the exported ML model. It is recommended to link the core runtime to the components that use ExecuTorch directly, and link kernels and backends against the main app target. + +Note: To access logs, link against the Debug build of the ExecuTorch runtime, i.e., the executorch_debug framework. For optimal performance, always link against the Release version of the deliverables (those without the _debug suffix), which have all logging overhead removed. + +For more details integrating and Running ExecuTorch on Apple Platforms, checkout this [link](https://pytorch.org/executorch/main/apple-runtime.html). + +### XCode * Open XCode and select "Open an existing project" to open `examples/demo-apps/apple_ios/LLama`. -* Ensure that the ExecuTorch package dependencies are installed correctly. +* Ensure that the ExecuTorch package dependencies are installed correctly, then select which ExecuTorch framework should link against which target. + +

+iOS LLaMA App Swift PM +

+ +

+iOS LLaMA App Choosing package +

+ * Run the app. This builds and launches the app on the phone. * In app UI pick a model and tokenizer to use, type a prompt and tap the arrow buton - ## Copy the model to Simulator * Drag&drop the model and tokenizer files onto the Simulator window and save them somewhere inside the iLLaMA folder. diff --git a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md index 8bbe64561f3..c327e2175fd 100644 --- a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md +++ b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md @@ -39,10 +39,10 @@ Install dependencies ## Prepare Models In this demo app, we support text-only inference with Llama 3.1, Llama 3, and Llama 2 models. -Install the required packages +Install the required packages to export the model ``` -executorch/examples/models/llama2/install_requirements.sh +sh examples/models/llama2/install_requirements.sh ``` Export the model @@ -78,6 +78,21 @@ The prebuilt ExecuTorch runtime, backend, and kernels are available as a Swift P ### Xcode Open the project in Xcode.In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version, e.g., “0.3.0”, or just use the “latest” branch name for the latest stable build. +Note: If you're running into any issues related to package dependencies, quit Xcode entirely, delete the whole executorch repo, clean the caches by running the command below in terminal and clone the repo again. + +```rm -rf \ + ~/Library/org.swift.swiftpm \ + ~/Library/Caches/org.swift.swiftpm \ + ~/Library/Caches/com.apple.dt.Xcode \ + ~/Library/Developer/Xcode/DerivedData +``` + +Link your binary with the ExecuTorch runtime and any backends or kernels used by the exported ML model. It is recommended to link the core runtime to the components that use ExecuTorch directly, and link kernels and backends against the main app target. + +Note: To access logs, link against the Debug build of the ExecuTorch runtime, i.e., the executorch_debug framework. For optimal performance, always link against the Release version of the deliverables (those without the _debug suffix), which have all logging overhead removed. + +For more details integrating and Running ExecuTorch on Apple Platforms, checkout this [link](https://pytorch.org/executorch/main/apple-runtime.html). +

iOS LLaMA App Swift PM

diff --git a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md index ba4bd4921a5..cf4b931cf1b 100644 --- a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md +++ b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md @@ -39,10 +39,10 @@ Install dependencies ## Prepare Models In this demo app, we support text-only inference with up-to-date Llama models. -Install the required packages +Install the required packages to export the model ``` -executorch/examples/models/llama2/install_requirements.sh +sh examples/models/llama2/install_requirements.sh ``` Export the model @@ -78,6 +78,21 @@ The prebuilt ExecuTorch runtime, backend, and kernels are available as a Swift P ### Xcode Open the project in Xcode.In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version, e.g., “0.3.0”, or just use the “latest” branch name for the latest stable build. +Note: If you're running into any issues related to package dependencies, quit Xcode entirely, delete the whole executorch repo, clean the caches by running the command below in terminal and clone the repo again. + +```rm -rf \ + ~/Library/org.swift.swiftpm \ + ~/Library/Caches/org.swift.swiftpm \ + ~/Library/Caches/com.apple.dt.Xcode \ + ~/Library/Developer/Xcode/DerivedData +``` + +Link your binary with the ExecuTorch runtime and any backends or kernels used by the exported ML model. It is recommended to link the core runtime to the components that use ExecuTorch directly, and link kernels and backends against the main app target. + +Note: To access logs, link against the Debug build of the ExecuTorch runtime, i.e., the executorch_debug framework. For optimal performance, always link against the Release version of the deliverables (those without the _debug suffix), which have all logging overhead removed. + +For more details integrating and Running ExecuTorch on Apple Platforms, checkout this [link](https://pytorch.org/executorch/main/apple-runtime.html). +

iOS LLaMA App Swift PM