Skip to content

Commit f799c0e

Browse files
cccclaifacebook-github-bot
authored andcommitted
add runner android build ci (#2733)
Summary: As title, add a new CI to cover cross compile android build for llama runner Pull Request resolved: #2733 Reviewed By: kimishpatel Differential Revision: D55512563 Pulled By: cccclai fbshipit-source-id: a9089abc2acfac4f61750933a86facae639f1b8e
1 parent 05b0d3a commit f799c0e

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
# shellcheck source=/dev/null
11+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
12+
13+
install_executorch_and_backend_lib() {
14+
echo "Installing executorch and xnnpack backend"
15+
rm -rf cmake-android-out && mkdir cmake-android-out
16+
ANDROID_NDK=/opt/ndk
17+
BUCK2=buck2
18+
ANDROID_ABI=arm64-v8a
19+
cmake -DBUCK2="${BUCK2}" \
20+
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
21+
-DANDROID_ABI="${ANDROID_ABI}" \
22+
-DANDROID_PLATFORM=android-23 \
23+
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
24+
-DCMAKE_BUILD_TYPE=Release \
25+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
26+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
27+
-DEXECUTORCH_BUILD_XNNPACK=ON \
28+
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
29+
-DXNNPACK_ENABLE_ARM_BF16=OFF \
30+
-Bcmake-android-out .
31+
32+
cmake --build cmake-android-out -j4 --target install --config Release
33+
}
34+
35+
build_llama_runner() {
36+
echo "Building llama runner for Android..."
37+
ANDROID_ABI=arm64-v8a
38+
cmake -DBUCK2="${BUCK2}" \
39+
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake \
40+
-DANDROID_ABI="${ANDROID_ABI}" \
41+
-DANDROID_PLATFORM=android-23 \
42+
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
43+
-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=python \
44+
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
45+
-Bcmake-android-out/examples/models/llama2 examples/models/llama2
46+
47+
cmake --build cmake-android-out/examples/models/llama2 -j4 --config Release
48+
}
49+
install_flatc_from_source
50+
install_executorch_and_backend_lib
51+
build_llama_runner

.github/workflows/pull.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ jobs:
114114
# Test llama2
115115
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M.pt "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
116116
117+
test-llama-runner-linux-android:
118+
name: test-llama-runner-linux-android
119+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
120+
strategy:
121+
matrix:
122+
include:
123+
- build-tool: cmake
124+
fail-fast: false
125+
with:
126+
runner: linux.2xlarge
127+
docker-image: executorch-ubuntu-22.04-clang12-android
128+
submodules: 'true'
129+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
130+
timeout: 90
131+
script: |
132+
# The generic Linux job chooses to use base env, not the one setup by the image
133+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
134+
conda activate "${CONDA_ENV}"
135+
136+
BUILD_TOOL=${{ matrix.build-tool }}
137+
PYTHON_EXECUTABLE=python \
138+
bash .ci/scripts/build_llama_android.sh "${BUILD_TOOL}"
139+
117140
test-custom-ops-linux:
118141
name: test-custom-ops-linux
119142
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main

0 commit comments

Comments
 (0)