Skip to content

Commit 52f1807

Browse files
jathujathu
jathu
authored andcommitted
make extension_module static
1 parent ea2029d commit 52f1807

File tree

8 files changed

+18
-40
lines changed

8 files changed

+18
-40
lines changed

Diff for: .ci/scripts/test_llama.sh

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ UPLOAD_DIR="${UPLOAD_DIR:-}"
5252
PT2E_QUANTIZE="${PT2E_QUANTIZE:-}"
5353

5454
# Default CMake Build Type to release mode
55-
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
55+
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug}
5656

5757
if [[ $# -lt 4 ]]; then # Assuming 4 mandatory args
5858
echo "Expecting atleast 4 positional arguments"
@@ -150,7 +150,7 @@ fi
150150
which "${PYTHON_EXECUTABLE}"
151151

152152
cmake_install_executorch_libraries() {
153-
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
153+
echo "Installing libexecutorch.a, libextension_module.a, libportable_ops_lib.a"
154154
rm -rf cmake-out
155155
retry cmake \
156156
-DCMAKE_INSTALL_PREFIX=cmake-out \
@@ -168,7 +168,7 @@ cmake_install_executorch_libraries() {
168168
-DQNN_SDK_ROOT="$QNN_SDK_ROOT" \
169169
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
170170
-Bcmake-out .
171-
cmake --build cmake-out -j9 --target install --config "$CMAKE_BUILD_TYPE"
171+
cmake --build cmake-out -j $(nproc) --target install --config "$CMAKE_BUILD_TYPE"
172172
}
173173

174174
cmake_build_llama_runner() {
@@ -187,7 +187,7 @@ cmake_build_llama_runner() {
187187
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
188188
-Bcmake-out/${dir} \
189189
${dir}
190-
cmake --build cmake-out/${dir} -j9 --config "$CMAKE_BUILD_TYPE"
190+
cmake --build cmake-out/${dir} -j $(nproc) --config "$CMAKE_BUILD_TYPE"
191191

192192
}
193193

Diff for: docs/source/llm/getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ add_executable(nanogpt_runner main.cpp)
376376
target_link_libraries(
377377
nanogpt_runner
378378
PRIVATE executorch
379-
extension_module_static # Provides the Module class
379+
extension_module # Provides the Module class
380380
extension_tensor # Provides the TensorPtr class
381381
optimized_native_cpu_ops_lib # Provides baseline cross-platform
382382
# kernels
@@ -533,7 +533,7 @@ add_executable(nanogpt_runner main.cpp)
533533
target_link_libraries(
534534
nanogpt_runner
535535
PRIVATE executorch
536-
extension_module_static # Provides the Module class
536+
extension_module # Provides the Module class
537537
extension_tensor # Provides the TensorPtr class
538538
optimized_native_cpu_ops_lib # Provides baseline cross-platform
539539
# kernels
@@ -672,7 +672,7 @@ target_link_libraries(
672672
nanogpt_runner
673673
PRIVATE
674674
executorch
675-
extension_module_static # Provides the Module class
675+
extension_module # Provides the Module class
676676
optimized_native_cpu_ops_lib # Provides baseline cross-platform kernels
677677
xnnpack_backend) # Provides the XNNPACK CPU acceleration backend
678678
```

Diff for: examples/llm_manual/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ add_executable(nanogpt_runner main.cpp)
2727
target_link_libraries(
2828
nanogpt_runner
2929
PRIVATE executorch
30-
extension_module_static # Provides the Module class
30+
extension_module # Provides the Module class
3131
extension_tensor # Provides the TensorPtr class
3232
optimized_native_cpu_ops_lib # Provides baseline cross-platform
3333
# kernels

Diff for: examples/models/phi-3-mini/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ target_include_directories(
4949
${CMAKE_CURRENT_SOURCE_DIR}/../../../extension/llm/tokenizers/include
5050
)
5151
target_link_libraries(
52-
phi_3_mini_runner PRIVATE executorch extension_module_static extension_tensor
52+
phi_3_mini_runner PRIVATE executorch extension_module extension_tensor
5353
optimized_native_cpu_ops_lib xnnpack_backend gflags
5454
)

Diff for: extension/module/CMakeLists.txt

+2-22
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,16 @@ if(NOT EXECUTORCH_ROOT)
1717
endif()
1818

1919
list(TRANSFORM _extension_module__srcs PREPEND "${EXECUTORCH_ROOT}/")
20-
if(CMAKE_TOOLCHAIN_IOS
21-
OR CMAKE_TOOLCHAIN_ANDROID
22-
OR APPLE
23-
)
24-
# Building a share library on iOS requires code signing On Android we see
25-
# duplicated registration when using shared lib
26-
add_library(extension_module STATIC ${_extension_module__srcs})
27-
else()
28-
add_library(extension_module SHARED ${_extension_module__srcs})
29-
endif()
20+
add_library(extension_module ${_extension_module__srcs})
3021
target_link_libraries(extension_module PRIVATE executorch extension_data_loader extension_flat_tensor)
3122
target_include_directories(extension_module PUBLIC ${EXECUTORCH_ROOT}/..)
3223
target_compile_options(
3324
extension_module PUBLIC -Wno-deprecated-declarations -fPIC
3425
)
3526

36-
# Module extension built as a static library. TODO(gjcomer) Remove this target
37-
# after cleaning up CMake targets.
38-
add_library(extension_module_static STATIC ${_extension_module__srcs})
39-
target_link_libraries(
40-
extension_module_static PRIVATE executorch extension_data_loader extension_flat_tensor
41-
)
42-
target_include_directories(extension_module_static PUBLIC ${EXECUTORCH_ROOT}/..)
43-
target_compile_options(
44-
extension_module_static PUBLIC -Wno-deprecated-declarations -fPIC
45-
)
46-
4727
# Install libraries
4828
install(
49-
TARGETS extension_module extension_module_static
29+
TARGETS extension_module
5030
DESTINATION lib
5131
INCLUDES
5232
DESTINATION ${_common_include_directories}

Diff for: extension/module/test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ et_cxx_test(
2525
${_test_srcs}
2626
EXTRA_LIBS
2727
extension_data_loader
28-
extension_module_static
28+
extension_module
2929
extension_tensor
3030
portable_kernels
3131
portable_ops_lib

Diff for: tools/cmake/cmake_deps.toml

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ filters = [
185185
deps = [
186186
"extension_flat_tensor_schema",
187187
"executorch_core",
188+
"extension_data_loader",
188189
"executorch",
189190
]
190191

@@ -199,6 +200,7 @@ deps = [
199200
"executorch",
200201
"executorch_core",
201202
"extension_data_loader",
203+
"extension_flat_tensor",
202204
]
203205

204206
[targets.extension_runner_util]

Diff for: tools/cmake/executorch-config.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ endif()
6565
set(lib_list
6666
etdump
6767
bundled_program
68+
extension_flat_tensor
6869
extension_data_loader
6970
${FLATCCRT_LIB}
7071
coreml_util
@@ -76,7 +77,6 @@ set(lib_list
7677
portable_ops_lib
7778
custom_ops
7879
extension_module
79-
extension_module_static
8080
extension_runner_util
8181
extension_tensor
8282
extension_threadpool
@@ -113,13 +113,9 @@ foreach(lib ${lib_list})
113113
If needed rebuild with the proper options in CMakeLists.txt"
114114
)
115115
else()
116-
if("${lib}" STREQUAL "extension_module" AND (NOT CMAKE_TOOLCHAIN_IOS))
117-
add_library(${lib} SHARED IMPORTED)
118-
else()
119-
# Building a share library on iOS requires code signing, so it's easier to
120-
# keep all libs as static when CMAKE_TOOLCHAIN_IOS is used
121-
add_library(${lib} STATIC IMPORTED)
122-
endif()
116+
# Building a share library on iOS requires code signing, so it's easier to
117+
# keep all libs as static when CMAKE_TOOLCHAIN_IOS is used
118+
add_library(${lib} STATIC IMPORTED)
123119
set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var}}")
124120
target_include_directories(
125121
${lib}

0 commit comments

Comments
 (0)