Skip to content

Commit efcae39

Browse files
committed
[NOT FOR LAND] Generate and upload android prebuilt
1 parent 47bc4aa commit efcae39

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

.github/workflows/android.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ on:
1010
- .ci/docker/**
1111
- .github/workflows/android.yml
1212
- install_requirements.sh
13-
- examples/demo-apps/**
13+
- examples/demo-apps/android/**
14+
- extension/android/**
1415
- extension/module/**
1516
workflow_dispatch:
1617

@@ -21,7 +22,7 @@ concurrency:
2122
jobs:
2223
test-demo-android:
2324
name: test-demo-android
24-
uses: pytorch/test-infra/.github/workflows/linux_job.yml@release/2.3
25+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
2526
strategy:
2627
matrix:
2728
include:
@@ -33,6 +34,7 @@ jobs:
3334
submodules: 'true'
3435
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
3536
timeout: 90
37+
upload-artifact: android-apps
3638
script: |
3739
set -eux
3840
@@ -45,3 +47,45 @@ jobs:
4547
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
4648
# Build Android demo app
4749
bash build/test_android_ci.sh
50+
51+
mkdir -p artifacts-to-be-uploaded
52+
mkdir -p artifacts-to-be-uploaded/arm64-v8a/
53+
mkdir -p artifacts-to-be-uploaded/x86_64/
54+
# Copy the jar to S3
55+
cp extension/android/build/libs/executorch.jar artifacts-to-be-uploaded/
56+
# Copy the app and its test suite to S3
57+
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/debug/*.apk artifacts-to-be-uploaded/
58+
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/androidTest/debug/*.apk artifacts-to-be-uploaded/
59+
# Also copy the libraries
60+
cp cmake-out-android-arm64-v8a/lib/*.a artifacts-to-be-uploaded/arm64-v8a/
61+
cp cmake-out-android-arm64-v8a/extension/android/*.so artifacts-to-be-uploaded/arm64-v8a/
62+
cp cmake-out-android-x86_64/lib/*.a artifacts-to-be-uploaded/x86_64/
63+
cp cmake-out-android-x86_64/extension/android/*.so artifacts-to-be-uploaded/x86_64/
64+
65+
# Upload the app and its test suite to S3 so that they can be downloaded by the test job
66+
upload-artifacts:
67+
needs: test-demo-android
68+
runs-on: linux.2xlarge
69+
steps:
70+
- name: Download the artifacts
71+
uses: actions/download-artifact@v3
72+
with:
73+
# The name here needs to match the name of the upload-artifact parameter
74+
name: android-apps
75+
path: ${{ runner.temp }}/artifacts/
76+
77+
- name: Verify the artifacts
78+
shell: bash
79+
working-directory: ${{ runner.temp }}/artifacts/
80+
run: |
81+
ls -lah ./
82+
83+
- name: Upload the artifacts to S3
84+
uses: seemethere/upload-artifact-s3@v5
85+
with:
86+
s3-bucket: gha-artifacts
87+
s3-prefix: |
88+
${{ github.repository }}/${{ github.run_id }}/artifact
89+
retention-days: 14
90+
if-no-files-found: ignore
91+
path: ${{ runner.temp }}/artifacts/

build/test_android_ci.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
set -ex
99

1010
# https://github.com/pytorch/executorch/tree/main/examples/demo-apps/android/ExecuTorchDemo
11-
build_executorch() {
11+
export_model() {
1212
MODEL_NAME=dl3
1313
# Delegating DeepLab v3 to XNNPACK backend
1414
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate
1515

1616
ASSETS_DIR=examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/
1717
mkdir -p "${ASSETS_DIR}"
1818
cp "${MODEL_NAME}_xnnpack_fp32.pte" "${ASSETS_DIR}"
19+
}
1920

20-
rm -rf cmake-out && mkdir cmake-out
21-
ANDROID_NDK=/opt/ndk BUCK2=$(which buck2) FLATC=$(which flatc) ANDROID_ABI=arm64-v8a \
22-
bash examples/demo-apps/android/ExecuTorchDemo/setup.sh
21+
build_android_native_library() {
22+
pushd examples/demo-apps/android/LlamaDemo
23+
CMAKE_OUT="cmake-out-android-$1" ANDROID_NDK=/opt/ndk ANDROID_ABI="$1" ./gradlew setup
24+
popd
2325
}
2426

2527
build_android_demo_app() {
@@ -30,11 +32,13 @@ build_android_demo_app() {
3032

3133
build_android_llama_demo_app() {
3234
pushd examples/demo-apps/android/LlamaDemo
33-
ANDROID_NDK=/opt/ndk ANDROID_ABI=arm64-v8a ./gradlew setup
3435
ANDROID_HOME=/opt/android/sdk ./gradlew build
36+
ANDROID_HOME=/opt/android/sdk ./gradlew assembleAndroidTest
3537
popd
3638
}
3739

38-
build_executorch
40+
build_android_native_library arm64-v8a
41+
build_android_native_library x86_64
42+
export_model
3943
build_android_demo_app
4044
build_android_llama_demo_app

0 commit comments

Comments
 (0)