Skip to content

Commit 88b49a3

Browse files
authored
Handle custom_ops like any other ET lib in Android and examples/models/lla{m,v}a/CMakeLists.txt (#8946)
The old way was a holdover from when custom_ops lived in examples/models/llama (and was copy/pasted to llava and Android). Needed for #8947.
1 parent a7dad09 commit 88b49a3

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed

build/cmake_deps.toml

+16
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ deps = [
5858
"executorch_core",
5959
]
6060

61+
# HACK: prevent reduce_util from also showing up in custom_ops. The
62+
# actual medium-term fix is to stop using Buck to drive our CMake
63+
# builds.
64+
[targets.reduce_util]
65+
buck_targets = [
66+
"//kernels/portable/cpu/util:reduce_util",
67+
]
68+
filters = [
69+
".cpp$",
70+
]
71+
deps = [
72+
"executorch",
73+
"executorch_core",
74+
]
75+
6176
[targets.optimized_kernels]
6277
buck_targets = [
6378
"//kernels/optimized:generated_lib",
@@ -414,6 +429,7 @@ deps = [
414429
"optimized_kernels",
415430
"extension_parallel",
416431
"extension_threadpool",
432+
"reduce_util",
417433
"xnnpack_backend",
418434
]
419435

build/executorch-config.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ set(lib_list
6565
neuron_backend
6666
qnn_executorch_backend
6767
portable_ops_lib
68+
custom_ops
6869
extension_module
6970
extension_module_static
7071
extension_parallel

examples/models/llama/CMakeLists.txt

+2-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ~~~
1616
# It should also be cmake-lint clean.
1717
#
18-
cmake_minimum_required(VERSION 3.19)
18+
cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE
1919
project(llama_runner)
2020

2121
# Duplicating options as root CMakeLists.txt
@@ -84,14 +84,6 @@ if(CMAKE_TOOLCHAIN_IOS OR ANDROID)
8484
target_link_options_shared_lib(executorch)
8585
endif()
8686

87-
# custom ops library
88-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
89-
add_subdirectory(
90-
${CMAKE_CURRENT_SOURCE_DIR}/../../../extension/llm/custom_ops
91-
${CMAKE_CURRENT_BINARY_DIR}/../../../extension/llm/custom_ops
92-
)
93-
endif()
94-
9587
# llama_runner library
9688
add_subdirectory(runner)
9789

@@ -119,8 +111,7 @@ target_link_options_shared_lib(quantized_ops_lib)
119111
list(APPEND link_libraries quantized_kernels quantized_ops_lib)
120112

121113
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
122-
target_link_options_shared_lib(custom_ops)
123-
list(APPEND link_libraries custom_ops)
114+
list(APPEND link_libraries $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
124115
endif()
125116

126117
if(EXECUTORCH_BUILD_TORCHAO)

examples/models/llava/CMakeLists.txt

-9
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,6 @@ if(CMAKE_TOOLCHAIN_IOS OR ANDROID)
9393
target_link_options_shared_lib(executorch)
9494
endif()
9595

96-
# custom ops library
97-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
98-
add_subdirectory(
99-
${EXECUTORCH_ROOT}/extension/llm/custom_ops
100-
${CMAKE_CURRENT_BINARY_DIR}/../../../extension/llm/custom_ops
101-
)
102-
endif()
103-
10496
# llava_runner library
10597
add_subdirectory(runner)
10698

@@ -132,7 +124,6 @@ target_link_options_shared_lib(quantized_ops_lib)
132124
list(APPEND link_libraries quantized_kernels quantized_ops_lib)
133125

134126
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
135-
target_link_options_shared_lib(custom_ops)
136127
list(APPEND link_libraries custom_ops)
137128
endif()
138129

extension/android/CMakeLists.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
cmake_minimum_required(VERSION 3.19)
7+
cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE
88

99
project(executorch_jni)
1010

@@ -115,12 +115,7 @@ if(TARGET vulkan_backend)
115115
endif()
116116

117117
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
118-
add_subdirectory(
119-
${EXECUTORCH_ROOT}/extension/llm/custom_ops
120-
${CMAKE_CURRENT_BINARY_DIR}/../../extension/llm/custom_ops
121-
)
122-
list(APPEND link_libraries custom_ops)
123-
target_link_options_shared_lib(custom_ops)
118+
list(APPEND link_libraries $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
124119
endif()
125120

126121
if(TARGET pthreadpool)

0 commit comments

Comments
 (0)