Skip to content

Update XNNPACK to CMake Fix #11856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: gh/mcr229/30/head
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ if(EXECUTORCH_BUILD_PYBIND)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and microkernels-prod here otherwise
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here otherwise
# uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _dep_libs xnnpack_backend XNNPACK microkernels-prod)
list(APPEND _dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
endif()

# compile options for pybind
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ set(XNNPACK_BUILD_ALL_MICROKERNELS
add_subdirectory("${XNNPACK_SOURCE_DIR}")
include_directories(SYSTEM ${XNNPACK_INCLUDE_DIR})
list(APPEND xnnpack_third_party XNNPACK)
install(TARGETS microkernels-prod
install(TARGETS xnnpack-microkernels-prod
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ et_cxx_test(
XNNPACK
pthreadpool
cpuinfo
microkernels-prod
xnnpack-microkernels-prod
)
target_include_directories(
backends_xnnpack_test
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/third-party/XNNPACK
Submodule XNNPACK updated 12520 files
35 changes: 33 additions & 2 deletions backends/xnnpack/third-party/xnnpack_src_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,38 @@ load(
_OPERATOR_SRCS = "OPERATOR_SRCS",
_SUBGRAPH_SRCS = "SUBGRAPH_SRCS",
_TABLE_SRCS = "TABLE_SRCS",
_XNNPACK_SRCS = "XNNPACK_SRCS",
# _MICROKERNEL_DEFS = "MICROKERNEL_DEFS",
# _MICROKERNEL_SRCS = "MICROKERNEL_SRCS",
)
load("//backends/xnnpack/third-party/XNNPACK/gen:microkernels.bzl", "prod_srcs_for_arch")
load("@fbsource//xplat/executorch/third-party:glob_defs.bzl", "subdir_glob")

_XNNPACK_SRCS = [
"src/configs/argmaxpool-config.c",
"src/configs/avgpool-config.c",
"src/configs/binary-elementwise-config.c",
"src/configs/cmul-config.c",
"src/configs/conv-hwc2chw-config.c",
"src/configs/dwconv-config.c",
"src/configs/dwconv2d-chw-config.c",
"src/configs/gemm-config.c",
"src/configs/ibilinear-chw-config.c",
"src/configs/ibilinear-config.c",
"src/configs/lut32norm-config.c",
"src/configs/maxpool-config.c",
"src/configs/pack-lh-config.c",
"src/configs/raddstoreexpminusmax-config.c",
"src/configs/reduce-config.c",
"src/configs/spmm-config.c",
"src/configs/transpose-config.c",
"src/configs/unary-elementwise-config.c",
"src/configs/unpool-config.c",
"src/configs/vmulcaddc-config.c",
"src/configs/x8-lut-config.c",
"src/configs/xx-fill-config.c",
"src/configs/xx-pad-config.c",
]

def define_xnnpack_build_src(xnnpack_build_src):
return ["XNNPACK/{}".format(src) for src in xnnpack_build_src]

Expand All @@ -18,10 +45,12 @@ def prod_srcs_for_arch_wrapper(arch):

def get_xnnpack_headers():
src_headers = subdir_glob([
("XNNPACK/src", "**/*.h"),
("xnnpack/src", "**/*.h"),
("xnnpack/src", "**/*.inc"),
])
include_headers = subdir_glob([
("XNNPACK/include", "*.h"),
("XNNPACK/include", "*.inc"),
])

return src_headers | include_headers
Expand All @@ -31,3 +60,5 @@ SUBGRAPH_SRCS = define_xnnpack_build_src(_SUBGRAPH_SRCS)
TABLE_SRCS = define_xnnpack_build_src(_TABLE_SRCS)
XNNPACK_SRCS = define_xnnpack_build_src(_XNNPACK_SRCS)
LOGGING_SRCS = define_xnnpack_build_src(_LOGGING_SRCS)
# MICROKERNEL_DEFS = define_xnnpack_build_src(_MICROKERNEL_DEFS)
# MICROKERNEL_SRCS = define_xnnpack_build_src(_MICROKERNEL_SRCS)
2 changes: 1 addition & 1 deletion examples/models/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ endif()

# XNNPACK
if(TARGET xnnpack_backend)
set(xnnpack_backend_libs xnnpack_backend XNNPACK microkernels-prod)
set(xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
if(TARGET kleidiai)
list(APPEND xnnpack_backend_libs kleidiai)
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ endif()

# XNNPACK
if(TARGET xnnpack_backend)
set(xnnpack_backend_libs xnnpack_backend XNNPACK microkernels-prod)
set(xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
if(TARGET kleidiai)
list(APPEND xnnpack_backend_libs kleidiai)
endif()
Expand Down
2 changes: 1 addition & 1 deletion extension/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ endif()

if(TARGET xnnpack_backend)
target_link_options_shared_lib(xnnpack_backend)
list(APPEND link_libraries xnnpack_backend XNNPACK pthreadpool cpuinfo microkernels-prod)
list(APPEND link_libraries xnnpack_backend XNNPACK pthreadpool cpuinfo xnnpack-microkernels-prod)
endif()

if(TARGET vulkan_backend)
Expand Down
4 changes: 2 additions & 2 deletions extension/training/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ if(EXECUTORCH_BUILD_PYBIND)
)

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and microkernels-prod
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK microkernels-prod)
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
endif()

# pybind training
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_apple_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ libmpsdelegate.a,\
FRAMEWORK_BACKEND_XNNPACK="backend_xnnpack:\
libXNNPACK.a,\
libxnnpack_backend.a,\
libmicrokernels-prod.a,\
libxnnpack-microkernels-prod.a,\
:"

FRAMEWORK_KERNELS_CUSTOM="kernels_custom:\
Expand Down
2 changes: 1 addition & 1 deletion tools/cmake/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ set(lib_list
xnnpack_backend
# Start XNNPACK Lib Deps
XNNPACK
microkernels-prod
xnnpack-microkernels-prod
kleidiai
# End XNNPACK Lib Deps
cpuinfo
Expand Down
Loading