Skip to content

Commit 5faaacb

Browse files
authored
Merge branch 'main' into docs/jhelsby/onboarding
2 parents 0c108f1 + 8d80185 commit 5faaacb

File tree

6 files changed

+178
-25
lines changed

6 files changed

+178
-25
lines changed

.ci/scripts/test_ios_ci.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
set -e
99

10-
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
10+
APP_PATH="executorch-examples/apple/ExecuTorchDemo/ExecuTorchDemo"
1111
MODEL_NAME="mv3"
1212
SIMULATOR_NAME="executorch"
1313

@@ -34,6 +34,10 @@ say() {
3434
echo -e "\033[1m\n\t** $1 **\n\033[0m"
3535
}
3636

37+
say "Cloning the Demo App"
38+
39+
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
40+
3741
say "Installing CoreML Backend Requirements"
3842

3943
./backends/apple/coreml/scripts/install_requirements.sh

.github/workflows/android-release-artifacts.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: Version name to be uploaded for AAR release
88
required: false
99
type: string
10+
upload_to_maven:
11+
description: Upload the AAR to maven staging repository
12+
required: false
13+
type: boolean
1014

1115
concurrency:
1216
group: ${{ github.workflow }}-${{ github.ref }}
@@ -31,11 +35,14 @@ jobs:
3135
build-aar:
3236
name: build-aar
3337
needs: check-if-aar-exists
34-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
38+
if: ${{ !github.event.pull_request.head.repo.fork }}
39+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7
40+
secrets: inherit
3541
permissions:
3642
id-token: write
3743
contents: read
3844
with:
45+
secrets-env: EXECUTORCH_MAVEN_SIGNING_KEYID EXECUTORCH_MAVEN_SIGNING_PASSWORD EXECUTORCH_MAVEN_CENTRAL_PASSWORD EXECUTORCH_MAVEN_CENTRAL_USERNAME EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS
3946
runner: linux.2xlarge
4047
docker-image: executorch-ubuntu-22.04-clang12-android
4148
submodules: 'true'
@@ -52,6 +59,16 @@ jobs:
5259
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
5360
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
5461
62+
mkdir -p ~/.gradle
63+
touch ~/.gradle/gradle.properties
64+
echo "signing.keyId=${SECRET_EXECUTORCH_MAVEN_SIGNING_KEYID}" >> ~/.gradle/gradle.properties
65+
echo "signing.password=${SECRET_EXECUTORCH_MAVEN_SIGNING_PASSWORD}" >> ~/.gradle/gradle.properties
66+
echo "mavenCentralUsername=${SECRET_EXECUTORCH_MAVEN_CENTRAL_USERNAME}" >> ~/.gradle/gradle.properties
67+
echo "mavenCentralPassword=${SECRET_EXECUTORCH_MAVEN_CENTRAL_PASSWORD}" >> ~/.gradle/gradle.properties
68+
echo "signing.secretKeyRingFile=/tmp/secring.gpg" >> ~/.gradle/gradle.properties
69+
70+
echo -n "$SECRET_EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS" | base64 -d > /tmp/secring.gpg
71+
5572
# Build AAR Package
5673
mkdir aar-out
5774
export BUILD_AAR_DIR=aar-out
@@ -61,6 +78,12 @@ jobs:
6178
6279
shasum -a 256 "${ARTIFACTS_DIR_NAME}/executorch.aar"
6380
81+
# Publish to maven staging
82+
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
83+
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
84+
(cd aar-out; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:publishToMavenCentral)
85+
fi
86+
6487
upload-release-aar:
6588
name: upload-release-aar
6689
needs: build-aar

docs/source/demo-apps-ios.md

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,141 @@
1-
```{include} ../../examples/demo-apps/apple_ios/ExecuTorchDemo/README.md
1+
# Building an ExecuTorch iOS Demo App
2+
3+
Welcome to the tutorial on setting up the ExecuTorch iOS Demo App!
4+
5+
This app uses the
6+
[MobileNet v3](https://pytorch.org/vision/main/models/mobilenetv3.html) model to
7+
process live camera images leveraging three different backends:
8+
[XNNPACK](https://github.com/google/XNNPACK),
9+
[Core ML](https://developer.apple.com/documentation/coreml) and
10+
[Metal Performance Shaders (MPS)](https://developer.apple.com/documentation/metalperformanceshaders)
11+
(Xcode 15+ and iOS 17+ only).
12+
13+
![](_static/img/demo_ios_app.jpg)
14+
15+
## Prerequisites
16+
17+
Before we start, make sure you have the following tools installed:
18+
19+
### 1. Xcode 15 and Command Line Tools
20+
21+
Install Xcode 15 from the
22+
[Mac App Store](https://apps.apple.com/app/xcode/id497799835) and then install
23+
the Command Line Tools using the terminal:
24+
25+
```bash
26+
xcode-select --install
27+
```
28+
29+
### 2. Python 3.10+
30+
31+
Python 3.10 or above, along with `pip`, should be pre-installed on MacOS 13.5+.
32+
If needed, [download Python](https://www.python.org/downloads/macos/) and
33+
install it. Verify the Python and pip versions using these commands:
34+
35+
```bash
36+
which python3 pip
37+
python3 --version
38+
pip --version
39+
```
40+
41+
### 3. Getting Started Tutorial
42+
43+
Follow the [Setting Up ExecuTorch](https://pytorch.org/executorch/stable/getting-started-setup)
44+
tutorial to configure the basic environment:
45+
46+
```bash
47+
git clone -b viable/strict https://github.com/pytorch/executorch.git && cd executorch
48+
49+
python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip
50+
51+
./install_executorch.sh
52+
```
53+
54+
### 4. Clone the Demo App
55+
56+
```bash
57+
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
58+
```
59+
60+
### 5. Backend Dependencies
61+
62+
Also, follow the corresponding sections from [Core ML](https://pytorch.org/executorch/stable/build-run-coreml) and
63+
[MPS](https://pytorch.org/executorch/stable/build-run-mps) tutorials to install additional dependencies for those
64+
backends:
65+
66+
```bash
67+
./backends/apple/coreml/scripts/install_requirements.sh
68+
69+
./backends/apple/mps/install_requirements.sh
70+
```
71+
72+
## Models and Labels
73+
74+
Now, let's move on to exporting and bundling the MobileNet v3 model.
75+
76+
### 1. Export Model
77+
78+
Export the MobileNet v3 model with Core ML, MPS and XNNPACK backends, and move
79+
the exported model to a specific location where the Demo App will pick them up:
80+
81+
```bash
82+
MODEL_NAME="mv3"
83+
84+
python3 -m examples.portable.scripts.export --model_name="$MODEL_NAME"
85+
python3 -m examples.apple.coreml.scripts.export --model_name="$MODEL_NAME"
86+
python3 -m examples.apple.mps.scripts.mps_example --model_name="$MODEL_NAME"
87+
python3 -m examples.xnnpack.aot_compiler --model_name="$MODEL_NAME" --delegate
88+
89+
APP_PATH="executorch-examples/apple/ExecuTorchDemo/ExecuTorchDemo"
90+
91+
mkdir -p "$APP_PATH/Resources/Models/MobileNet/"
92+
mv $MODEL_NAME*.pte "$APP_PATH/Resources/Models/MobileNet/"
93+
```
94+
95+
### 2. Download Labels
96+
97+
Download the MobileNet model labels required for image classification:
98+
99+
```bash
100+
curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \
101+
-o "$APP_PATH/Resources/Models/MobileNet/imagenet_classes.txt"
102+
```
103+
104+
## Final Steps
105+
106+
We're almost done! Now, we just need to open the project in Xcode, run the
107+
tests, and finally run the app.
108+
109+
### 1. Open Project in Xcode
110+
111+
Double-click on the project file under `executorch-examples/apple/ExecuTorchDemo` or run the command:
112+
113+
```bash
114+
open $APP_PATH.xcodeproj
115+
```
116+
117+
### 2. Run Tests
118+
119+
You can run tests on Simulaltor directly in Xcode with `Cmd + U` or use the
120+
command line:
121+
122+
```bash
123+
xcrun simctl create executorch "iPhone 15"
124+
xcodebuild clean test \
125+
-project $APP_PATH.xcodeproj \
126+
-scheme App \
127+
-destination name=executorch
128+
xcrun simctl delete executorch
129+
```
130+
131+
### 3. Run App
132+
133+
Finally, connect the device, set up Code Signing in Xcode, and then run the app
134+
using `Cmd + R`. Try installing a Release build for better performance.
135+
136+
Congratulations! You've successfully set up the ExecuTorch iOS Demo App. Now,
137+
you can explore and enjoy the power of ExecuTorch on your iOS device!
138+
139+
Learn more about integrating and running [ExecuTorch on Apple](https://pytorch.org/executorch/stable/apple-runtime) platforms.
140+
141+
![](_static/img/demo_ios_xcode.jpg)

extension/android/executorch_android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mavenPublishing {
4848
publishToMavenCentral(SonatypeHost.DEFAULT)
4949
signAllPublications()
5050

51-
coordinates("org.pytorch", "executorch-android", "0.5.0-SNAPSHOT")
51+
coordinates("org.pytorch", "executorch-android", "0.7.0")
5252

5353
pom {
5454
name = "ExecuTorch Android"

scripts/test_ios.sh

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -e
1515

1616
OUTPUT="${1:-executorch}"
1717
EXIT_STATUS=0
18-
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
18+
APP_PATH="executorch-examples/apple/ExecuTorchDemo/ExecuTorchDemo"
1919
MODEL_NAME="mv3"
2020
SIMULATOR_NAME="executorch"
2121

@@ -44,26 +44,17 @@ say() {
4444
echo -e "\033[1m\n\t** $1 **\n\033[0m"
4545
}
4646

47-
say "Cloning the Code"
48-
49-
pushd . > /dev/null
50-
git clone -b viable/strict https://github.com/pytorch/executorch.git "$OUTPUT"
51-
cd "$OUTPUT"
52-
53-
say "Updating the Submodules"
54-
55-
git submodule update --init
56-
5747
say "Activating a Virtual Environment"
5848

59-
python3 -m venv .venv
60-
source .venv/bin/activate
49+
python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip
6150

6251
say "Installing Requirements"
6352

64-
pip install --upgrade cmake pip setuptools wheel zstd
53+
./install_executorch.sh
6554

66-
./install_executorch.sh --pybind coreml mps xnnpack
55+
say "Cloning the Demo App"
56+
57+
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
6758

6859
say "Installing CoreML Backend Requirements"
6960

@@ -88,11 +79,6 @@ say "Downloading Labels"
8879
curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \
8980
-o "$APP_PATH/Resources/Models/MobileNet/imagenet_classes.txt"
9081

91-
say "Building Frameworks"
92-
93-
./scripts/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
94-
mv cmake-out "$APP_PATH/Frameworks"
95-
9682
say "Creating Simulator"
9783

9884
xcrun simctl create "$SIMULATOR_NAME" "iPhone 15"

third-party/ao

Submodule ao updated 79 files

0 commit comments

Comments
 (0)