Skip to content

Commit 904e989

Browse files
authored
[RELEASE ONLY] Android custom op registration (#3284)
* [Android] Fix upload workflow for release * [RELEASE ONLY] Android custom op registration
1 parent b3fb810 commit 904e989

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/demo-apps/android/LlamaDemo/setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
1616
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
1717
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
1818
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
19+
-DEXECUTORCH_BUILD_XNNPACK=ON \
1920
-DCMAKE_BUILD_TYPE=Release \
2021
-B"${CMAKE_OUT}"
2122

@@ -30,6 +31,7 @@ cmake examples/models/llama2 \
3031
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
3132
-DANDROID_ABI="$ANDROID_ABI" \
3233
-DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
34+
-DEXECUTORCH_BUILD_XNNPACK=ON \
3335
-DCMAKE_BUILD_TYPE=Release \
3436
-B"${CMAKE_OUT}"/examples/models/llama2
3537

extension/android/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
6161
set(CUSTOM_OPS_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama2/custom_ops/libcustom_ops.a)
6262
add_library(custom_ops STATIC IMPORTED)
6363
set_property(TARGET custom_ops PROPERTY IMPORTED_LOCATION ${CUSTOM_OPS_PATH})
64+
target_link_options_shared_lib(custom_ops)
65+
66+
set(CUSTOM_OPS_LIB_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama2/custom_ops/libcustom_ops_lib.a)
67+
add_library(custom_ops_lib STATIC IMPORTED)
68+
set_property(TARGET custom_ops_lib PROPERTY IMPORTED_LOCATION ${CUSTOM_OPS_LIB_PATH})
69+
target_link_options_shared_lib(custom_ops_lib)
6470

6571
if(TARGET pthreadpool)
6672
set(LLAMA_JNI_SRCS jni/jni_layer_llama.cpp ../../backends/xnnpack/threadpool/cpuinfo_utils.cpp)
@@ -77,6 +83,6 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
7783
endif()
7884
target_include_directories(executorch_llama_jni PRIVATE ${_common_include_directories})
7985
target_link_libraries(executorch_llama_jni ${link_libraries} llama_runner
80-
custom_ops cpublas eigen_blas)
86+
custom_ops custom_ops_lib cpublas eigen_blas)
8187
target_compile_options(executorch_llama_jni PUBLIC ${_common_compile_options})
8288
endif()

0 commit comments

Comments
 (0)