File tree Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,13 @@ build_aar() {
97
97
find jni -type f -name " libexecutorch_jni.so" -exec bash -c ' mv "$1" "${1/_jni/}"' bash {} \;
98
98
# Zip all necessary files into the AAR file
99
99
zip -r executorch.aar libs jni/* /libexecutorch.so jni/* /libqnn* .so jni/* /libQnn* .so AndroidManifest.xml
100
- zip -r executorch-llama.aar libs jni/* /libexecutorch_llama_jni .so jni/* /libqnn* .so jni/* /libQnn* .so AndroidManifest.xml
100
+ zip -r executorch-llama.aar libs jni/* /libexecutorch .so jni/* /libqnn* .so jni/* /libQnn* .so AndroidManifest.xml
101
101
popd
102
102
}
103
103
104
104
build_android_demo_apps () {
105
105
mkdir -p examples/demo-apps/android/LlamaDemo/app/libs
106
106
cp ${BUILD_AAR_DIR} /executorch-llama.aar examples/demo-apps/android/LlamaDemo/app/libs
107
- cp ${BUILD_AAR_DIR} /executorch-llama.aar extension/android/benchmark/app/libs/executorch.aar
108
107
pushd examples/demo-apps/android/LlamaDemo
109
108
ANDROID_HOME=" ${ANDROID_SDK:-/ opt/ android/ sdk} " ./gradlew build assembleAndroidTest
110
109
popd
@@ -140,6 +139,7 @@ collect_artifacts_to_be_uploaded() {
140
139
}
141
140
142
141
BUILD_AAR_DIR=" $( mktemp -d) "
142
+ export BUILD_AAR_DIR
143
143
if [ -z " $ANDROID_ABIS " ]; then
144
144
ANDROID_ABIS=(" arm64-v8a" " x86_64" )
145
145
fi
Original file line number Diff line number Diff line change @@ -78,11 +78,12 @@ if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
78
78
)
79
79
endif ()
80
80
81
- set ( JNI_SRCS jni/jni_layer.cpp )
81
+ add_library ( executorch_jni SHARED jni/jni_layer.cpp )
82
82
83
83
if (EXECUTORCH_BUILD_LLAMA_JNI )
84
- list ( APPEND JNI_SRCS jni/jni_layer_llama.cpp )
84
+ target_sources ( executorch_jni PRIVATE jni/jni_layer_llama.cpp )
85
85
list (APPEND link_libraries llama_runner llava_runner )
86
+ target_compile_definitions (executorch_jni PUBLIC EXECUTORCH_BUILD_LLAMA_JNI=1 )
86
87
add_subdirectory (
87
88
${EXECUTORCH_ROOT} /examples/models/llava/runner
88
89
${CMAKE_CURRENT_BINARY_DIR} /../../examples/models/llava/runner
@@ -98,8 +99,6 @@ if(TARGET quantized_kernels)
98
99
list (APPEND link_libraries quantized_kernels quantized_ops_lib )
99
100
endif ()
100
101
101
- add_library (executorch_jni SHARED ${JNI_SRCS} )
102
-
103
102
target_include_directories (
104
103
executorch_jni PRIVATE ${_common_include_directories}
105
104
)
Original file line number Diff line number Diff line change @@ -386,11 +386,15 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
386
386
};
387
387
} // namespace executorch::extension
388
388
389
- extern void register_natives_jni ();
390
-
389
+ #ifdef EXECUTORCH_BUILD_LLAMA_JNI
390
+ extern void register_natives_for_llama ();
391
+ #else
392
+ // No op if we don't build llama
393
+ void register_natives_for_llama () {}
394
+ #endif
391
395
JNIEXPORT jint JNICALL JNI_OnLoad (JavaVM* vm, void *) {
392
396
return facebook::jni::initialize (
393
397
vm, [] { executorch::extension::ExecuTorchJni::registerNatives ();
394
- register_natives_jni ();
398
+ register_natives_for_llama ();
395
399
});
396
400
}
Original file line number Diff line number Diff line change @@ -265,7 +265,6 @@ class ExecuTorchLlamaJni
265
265
266
266
} // namespace executorch_jni
267
267
268
- void register_natives_jni () {
268
+ void register_natives_for_llama () {
269
269
executorch_jni::ExecuTorchLlamaJni::registerNatives ();
270
270
}
271
-
You can’t perform that action at this time.
0 commit comments