Skip to content

Commit c4786f0

Browse files
author
Github Executorch
committed
Update on "Reuse GELU implementation from PyTorch core"
kernels/optimized doesn't need to support embedded systems, so it can just take a header-only dep on PyTorch. Note that, because we will pick up Sleef internally and ignore it externally thanks to ATen vec, this PR gets to enable optimized GELU in OSS. Testing: CI to make sure this doesn't break mobile build modes; happy to take advice on anything not currently covered that might break. Differential Revision: [D66335522](https://our.internmc.facebook.com/intern/diff/D66335522/) [ghstack-poisoned]
2 parents c8b91c7 + 763c11d commit c4786f0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
1414
PYTHON_EXECUTABLE=python3
1515
fi
1616
which "${PYTHON_EXECUTABLE}"
17+
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
18+
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
1719

1820
install_executorch_and_backend_lib() {
1921
echo "Installing executorch and xnnpack backend"
@@ -27,6 +29,7 @@ install_executorch_and_backend_lib() {
2729
-DANDROID_ABI="${ANDROID_ABI}" \
2830
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
2931
-DCMAKE_BUILD_TYPE=Release \
32+
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
3033
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3134
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3235
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
@@ -43,8 +46,6 @@ install_executorch_and_backend_lib() {
4346
build_llama_runner() {
4447
echo "Building llama runner for Android..."
4548
ANDROID_ABI=arm64-v8a
46-
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
47-
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
4849
cmake -DBUCK2="${BUCK2}" \
4950
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake \
5051
-DANDROID_ABI="${ANDROID_ABI}" \

build/build_android_llm_demo.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
set -ex
99

10+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
11+
PYTHON_EXECUTABLE=python3
12+
fi
13+
which "${PYTHON_EXECUTABLE}"
14+
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
15+
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
16+
1017
build_jar() {
1118
pushd extension/android
1219
./gradlew build
@@ -36,6 +43,7 @@ build_android_native_library() {
3643
fi
3744

3845
cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
46+
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
3947
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
4048
-DANDROID_ABI="${ANDROID_ABI}" \
4149
-DANDROID_PLATFORM=android-26 \
@@ -69,6 +77,7 @@ build_android_native_library() {
6977
-DANDROID_ABI="${ANDROID_ABI}" \
7078
-DANDROID_PLATFORM=android-26 \
7179
-DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
80+
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
7281
-DEXECUTORCH_ENABLE_LOGGING=ON \
7382
-DEXECUTORCH_LOG_LEVEL=Info \
7483
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \

0 commit comments

Comments
 (0)