Skip to content

Commit d46f329

Browse files
author
Yi Ren
committed
make examples/models/llama/runner build in win_x64
1 parent 19033e2 commit d46f329

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

examples/models/llama/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,21 @@ add_subdirectory(runner)
9898
set(link_libraries gflags)
9999
set(_srcs main.cpp)
100100

101+
# in Windows, cpublas and extension_threadpool have duplicated symbols
102+
if(WIN32 AND TARGET xnnpack_backend)
103+
set(CPUBLAS "")
104+
else()
105+
set(CPUBLAS "cpublas")
106+
endif()
107+
101108
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
102109
list(
103110
APPEND
104111
link_libraries
105112
optimized_native_cpu_ops_lib
106113
optimized_kernels
107114
portable_kernels
108-
cpublas
115+
${CPUBLAS}
109116
eigen_blas
110117
)
111118
target_link_options_shared_lib(optimized_native_cpu_ops_lib)
@@ -131,18 +138,26 @@ if(EXECUTORCH_BUILD_TORCHAO)
131138
endif()
132139

133140
set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
141+
142+
# in Windows, xnnpack_backend and extension_threadpool have duplicated symbols
143+
if(WIN32 AND TARGET xnnpack_backend)
144+
set(EXTENSION_THREADPOOL "")
145+
else()
146+
set(EXTENSION_THREADPOOL "extension_threadpool")
147+
endif()
148+
134149
# Extra compile option and include dir for pthreadpool
135150
if(EXECUTORCH_BUILD_PTHREADPOOL)
136151
list(APPEND _common_compile_options -DET_USE_THREADPOOL)
137-
list(APPEND link_libraries extension_threadpool pthreadpool)
152+
list(APPEND link_libraries ${EXTENSION_THREADPOOL} pthreadpool)
138153
list(APPEND _common_include_directories
139154
${XNNPACK_ROOT}/third-party/pthreadpool/include
140155
)
141156
endif()
142157

143158
# Extra sources for cpuinfo
144159
if(EXECUTORCH_BUILD_CPUINFO)
145-
list(APPEND link_libraries extension_threadpool cpuinfo)
160+
list(APPEND link_libraries ${EXTENSION_THREADPOOL} cpuinfo)
146161
list(APPEND _common_include_directories
147162
${XNNPACK_ROOT}/third-party/cpuinfo/include
148163
)

examples/models/llama/runner/CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ list(APPEND _llama_runner__srcs
5252
if(CMAKE_TOOLCHAIN_IOS
5353
OR ANDROID
5454
OR APPLE
55+
OR WIN32
5556
)
5657
# Building a share library on iOS requires code signing On Android we see
5758
# duplicated registration when using shared lib
@@ -75,13 +76,24 @@ add_subdirectory(
7576
)
7677
set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
7778

79+
if (WIN32)
80+
# in Windows, only extension_module_static works and has duplicated symbols with extension_tensor
81+
set(llama_runner_deps executorch extension_data_loader extension_module_static
82+
re2::re2
83+
)
84+
# in Windows, need PUBLIC or sources files in executorch/examples/models/llama/runner/ cannot be found
85+
target_include_directories(
86+
llama_runner PUBLIC ${_common_include_directories} ${EXECUTORCH_ROOT}
87+
)
88+
else()
7889
set(llama_runner_deps executorch extension_data_loader extension_module
7990
extension_tensor re2::re2
8091
)
81-
82-
target_link_libraries(llama_runner PUBLIC ${llama_runner_deps})
83-
8492
target_include_directories(
8593
llama_runner INTERFACE ${_common_include_directories} ${EXECUTORCH_ROOT}
8694
)
95+
endif()
96+
97+
target_link_libraries(llama_runner PUBLIC ${llama_runner_deps})
98+
8799
target_compile_options(llama_runner PUBLIC ${_preprocessor_flag})

0 commit comments

Comments
 (0)