Skip to content

Commit 6dd613a

Browse files
committed
[RELEASE ONLY] Android custom op registration
1 parent ed23bc0 commit 6dd613a

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
@@ -15,7 +15,9 @@ cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
1515
-DEXECUTORCH_BUILD_XNNPACK=ON \
1616
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
1717
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
18+
-DEXECUTORCH_BUILD_CUSTOM=ON \
1819
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
20+
-DEXECUTORCH_BUILD_XNNPACK=ON \
1921
-DCMAKE_BUILD_TYPE=Release \
2022
-B"${CMAKE_OUT}"
2123

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)