Skip to content

Commit 2f46787

Browse files
committed
Experimental
1 parent eeabc29 commit 2f46787

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ if(EXECUTORCH_BUILD_VULKAN)
943943
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
944944
endif()
945945

946+
if(ANDROID)
947+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
948+
endif()
949+
946950
include(Test.cmake)
947951

948952
# Print all summary

extension/android/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE
88

9-
project(executorch_jni)
9+
if(NOT EXECUTORCH_ROOT)
10+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
11+
endif()
1012

1113
if(NOT CMAKE_CXX_STANDARD)
1214
set(CMAKE_CXX_STANDARD 17)
@@ -16,7 +18,6 @@ if(NOT ANDROID)
1618
message(FATAL_ERROR "This directory is for Android build only")
1719
endif()
1820

19-
set(EXECUTORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
2021
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2122
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
2223
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
@@ -60,8 +61,6 @@ set_target_properties(fbjni PROPERTIES
6061
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so"
6162
)
6263

63-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
64-
find_package(executorch CONFIG REQUIRED)
6564
target_link_options_shared_lib(executorch)
6665

6766
add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp)
@@ -141,12 +140,12 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
141140
target_compile_definitions(executorch_jni PUBLIC EXECUTORCH_BUILD_LLAMA_JNI=1)
142141
add_subdirectory(
143142
${EXECUTORCH_ROOT}/examples/models/llava/runner
144-
${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llava/runner
143+
${CMAKE_CURRENT_BINARY_DIR}/examples/models/llava/runner
145144
)
146145

147146
add_subdirectory(
148147
${EXECUTORCH_ROOT}/examples/models/llama/runner
149-
${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama/runner
148+
${CMAKE_CURRENT_BINARY_DIR}/examples/models/llama/runner
150149
)
151150

152151
if(NEURON_BUFFER_ALLOCATOR_LIB)

scripts/build_android_library.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ build_android_native_library() {
5050
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
5151
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5252
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
53+
-DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
5354
-DEXECUTORCH_BUILD_NEURON="${EXECUTORCH_BUILD_NEURON}" \
5455
-DNEURON_BUFFER_ALLOCATOR_LIB="${NEURON_BUFFER_ALLOCATOR_LIB}" \
5556
-DEXECUTORCH_BUILD_QNN="${EXECUTORCH_BUILD_QNN}" \
@@ -65,23 +66,6 @@ build_android_native_library() {
6566
fi
6667
cmake --build "${CMAKE_OUT}" -j "${CMAKE_JOBS}" --target install --config "${EXECUTORCH_CMAKE_BUILD_TYPE}"
6768

68-
cmake extension/android \
69-
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
70-
-DANDROID_ABI="${ANDROID_ABI}" \
71-
-DANDROID_PLATFORM=android-26 \
72-
-DBUILD_TESTING=OFF \
73-
-DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
74-
-DEXECUTORCH_ENABLE_LOGGING=ON \
75-
-DEXECUTORCH_LOG_LEVEL=Info \
76-
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
77-
-DNEURON_BUFFER_ALLOCATOR_LIB="$NEURON_BUFFER_ALLOCATOR_LIB" \
78-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
79-
-DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
80-
-DCMAKE_BUILD_TYPE="${EXECUTORCH_CMAKE_BUILD_TYPE}" \
81-
-B"${CMAKE_OUT}"/extension/android
82-
83-
cmake --build "${CMAKE_OUT}"/extension/android -j "${CMAKE_JOBS}" --config "${EXECUTORCH_CMAKE_BUILD_TYPE}"
84-
8569
# Copy artifacts to ABI specific directory
8670
local SO_STAGE_DIR="cmake-out-android-so/${ANDROID_ABI}"
8771
mkdir -p ${SO_STAGE_DIR}

0 commit comments

Comments
 (0)