|
6 | 6 |
|
7 | 7 | cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE |
8 | 8 |
|
| 9 | +project(executorch_jni) |
| 10 | + |
| 11 | +include(ExternalProject) |
| 12 | + |
9 | 13 | if(NOT EXECUTORCH_ROOT) |
10 | 14 | set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) |
11 | 15 | endif() |
@@ -61,6 +65,36 @@ set_target_properties(fbjni PROPERTIES |
61 | 65 | IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" |
62 | 66 | ) |
63 | 67 |
|
| 68 | +ExternalProject_Add(executorch_root |
| 69 | + PREFIX executorch_root |
| 70 | + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." |
| 71 | + CMAKE_ARGS |
| 72 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE |
| 73 | + -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake |
| 74 | + -DANDROID_ABI=${ANDROID_ABI} |
| 75 | + -DANDROID_PLATFORM=android-26 |
| 76 | + -DBUILD_TESTING=OFF |
| 77 | + -DCMAKE_INSTALL_PREFIX=${CMAKE_OUT} |
| 78 | + -DEXECUTORCH_ENABLE_LOGGING=ON |
| 79 | + -DEXECUTORCH_LOG_LEVEL=Info |
| 80 | + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH |
| 81 | + -DEXECUTORCH_BUILD_XNNPACK=ON |
| 82 | + -DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON |
| 83 | + -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON |
| 84 | + -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON |
| 85 | + -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON |
| 86 | + -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON |
| 87 | + -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON |
| 88 | + -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON |
| 89 | + -DEXECUTORCH_BUILD_KERNELS_CUSTOM=${EXECUTORCH_BUILD_EXTENSION_LLM} |
| 90 | + -DEXECUTORCH_BUILD_LLAMA_JNI=${EXECUTORCH_BUILD_EXTENSION_LLM} |
| 91 | + -DEXECUTORCH_BUILD_NEURON=${EXECUTORCH_BUILD_NEURON} |
| 92 | + -DNEURON_BUFFER_ALLOCATOR_LIB=${NEURON_BUFFER_ALLOCATOR_LIB} |
| 93 | + -DEXECUTORCH_BUILD_QNN=${EXECUTORCH_BUILD_QNN} |
| 94 | + -DQNN_SDK_ROOT=${QNN_SDK_ROOT} |
| 95 | + -DEXECUTORCH_BUILD_VULKAN=${EXECUTORCH_BUILD_VULKAN} |
| 96 | +) |
| 97 | + |
64 | 98 | target_link_options_shared_lib(executorch) |
65 | 99 |
|
66 | 100 | add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp) |
@@ -134,44 +168,6 @@ if(EXECUTORCH_JNI_CUSTOM_LIBRARY) |
134 | 168 | ) |
135 | 169 | endif() |
136 | 170 |
|
137 | | -if(EXECUTORCH_BUILD_LLAMA_JNI) |
138 | | - target_sources(executorch_jni PRIVATE jni/jni_layer_llama.cpp jni/log.cpp) |
139 | | - list(APPEND link_libraries llama_runner llava_runner) |
140 | | - target_compile_definitions(executorch_jni PUBLIC EXECUTORCH_BUILD_LLAMA_JNI=1) |
141 | | - add_subdirectory( |
142 | | - ${EXECUTORCH_ROOT}/examples/models/llava/runner |
143 | | - ${CMAKE_CURRENT_BINARY_DIR}/examples/models/llava/runner |
144 | | - ) |
145 | | - |
146 | | - add_subdirectory( |
147 | | - ${EXECUTORCH_ROOT}/examples/models/llama/runner |
148 | | - ${CMAKE_CURRENT_BINARY_DIR}/examples/models/llama/runner |
149 | | - ) |
150 | | - |
151 | | - if(NEURON_BUFFER_ALLOCATOR_LIB) |
152 | | - target_sources( |
153 | | - executorch_jni PRIVATE |
154 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/mtk_llama_runner.cpp |
155 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaModelChunk.cpp |
156 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaRuntime.cpp |
157 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/ModelChunk.cpp |
158 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/MultiModelLoader.cpp |
159 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/mask_builder.cpp |
160 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/rotary_embedding.cpp |
161 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/token_embedding.cpp |
162 | | - ) |
163 | | - target_include_directories( |
164 | | - executorch_jni PRIVATE |
165 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/ |
166 | | - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner |
167 | | - ) |
168 | | - add_library(libneuron_buffer_allocator SHARED IMPORTED) |
169 | | - set_property(TARGET libneuron_buffer_allocator PROPERTY IMPORTED_LOCATION ${NEURON_BUFFER_ALLOCATOR_LIB}) |
170 | | - list(APPEND link_libraries neuron_backend libneuron_buffer_allocator) |
171 | | - target_compile_definitions(executorch_jni PRIVATE EXECUTORCH_BUILD_MEDIATEK=1) |
172 | | - endif() |
173 | | -endif() |
174 | | - |
175 | 171 | target_include_directories( |
176 | 172 | executorch_jni PRIVATE ${_common_include_directories} |
177 | 173 | "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" |
|
0 commit comments