Skip to content

[RELEASE ONLY] Android custom op registration #3284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ jobs:
mkdir -p artifacts-to-be-uploaded/x86_64/
# Copy the jar to S3
cp extension/android/build/libs/executorch.jar artifacts-to-be-uploaded/
# Copy the app and its test suite to S3
# Copy the app to S3
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/debug/*.apk artifacts-to-be-uploaded/
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/androidTest/debug/*.apk artifacts-to-be-uploaded/
# Also copy the libraries
cp cmake-out-android-arm64-v8a/lib/*.a artifacts-to-be-uploaded/arm64-v8a/
cp cmake-out-android-arm64-v8a/extension/android/*.so artifacts-to-be-uploaded/arm64-v8a/
Expand Down
2 changes: 2 additions & 0 deletions examples/demo-apps/android/LlamaDemo/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DCMAKE_BUILD_TYPE=Release \
-B"${CMAKE_OUT}"

Expand All @@ -30,6 +31,7 @@ cmake examples/models/llama2 \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="$ANDROID_ABI" \
-DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DCMAKE_BUILD_TYPE=Release \
-B"${CMAKE_OUT}"/examples/models/llama2

Expand Down
8 changes: 7 additions & 1 deletion extension/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
set(CUSTOM_OPS_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama2/custom_ops/libcustom_ops.a)
add_library(custom_ops STATIC IMPORTED)
set_property(TARGET custom_ops PROPERTY IMPORTED_LOCATION ${CUSTOM_OPS_PATH})
target_link_options_shared_lib(custom_ops)

set(CUSTOM_OPS_LIB_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama2/custom_ops/libcustom_ops_lib.a)
add_library(custom_ops_lib STATIC IMPORTED)
set_property(TARGET custom_ops_lib PROPERTY IMPORTED_LOCATION ${CUSTOM_OPS_LIB_PATH})
target_link_options_shared_lib(custom_ops_lib)

if(TARGET pthreadpool)
set(LLAMA_JNI_SRCS jni/jni_layer_llama.cpp ../../backends/xnnpack/threadpool/cpuinfo_utils.cpp)
Expand All @@ -77,6 +83,6 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
endif()
target_include_directories(executorch_llama_jni PRIVATE ${_common_include_directories})
target_link_libraries(executorch_llama_jni ${link_libraries} llama_runner
custom_ops cpublas eigen_blas)
custom_ops custom_ops_lib cpublas eigen_blas)
target_compile_options(executorch_llama_jni PUBLIC ${_common_compile_options})
endif()
Loading