Skip to content

Commit 21944ef

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Mark optimized_kernels as a dependency for custom_ops. (#2764)
Summary: Pull Request resolved: #2764 Reviewed By: kirklandsign Differential Revision: D55535501 fbshipit-source-id: ace93dc0010cc4e5be23a97d9c3b7d5d475308d6
1 parent 3e2e26d commit 21944ef

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

build/cmake_deps.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ excludes = [
5656
# Exclude the codegen templates, which are picked up because the buck target
5757
# is the generated_lib and not the unwrapped set of kernels.
5858
"^codegen/templates",
59-
# Exclude blas, since it's built as a separate target.
60-
"^kernels/optimized/blas",
6159
]
6260
deps = [
6361
"executorch",
@@ -274,11 +272,11 @@ filters = [
274272
]
275273
excludes = [
276274
"^codegen",
277-
# Exclude blas, since it's built as a separate target.
278-
"^kernels/optimized/blas",
279275
]
280276
deps = [
281277
"executorch",
278+
"optimized_kernels",
279+
"xnnpack_backend",
282280
]
283281

284282
[targets.llama_runner]

examples/models/llama2/custom_ops/CMakeLists.txt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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-
87
cmake_minimum_required(VERSION 3.19)
98

109
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -44,7 +43,6 @@ include(${EXECUTORCH_SRCS_FILE})
4443
# Let files say "include <executorch/path/to/header.h>".
4544
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
4645

47-
4846
# Custom op libraries
4947
set(custom_ops_libs extension_module)
5048
list(APPEND custom_ops_libs pthreadpool)
@@ -57,25 +55,34 @@ list(APPEND custom_ops_libs eigen_blas)
5755
set(_yaml "${CMAKE_CURRENT_LIST_DIR}/custom_ops.yaml")
5856
gen_selected_ops("${_yaml}" "" "")
5957

60-
generate_bindings_for_kernels(
61-
FUNCTIONS_YAML ${CMAKE_CURRENT_SOURCE_DIR}/custom_ops.yaml)
58+
generate_bindings_for_kernels(FUNCTIONS_YAML
59+
${CMAKE_CURRENT_SOURCE_DIR}/custom_ops.yaml)
6260
message("Generated files ${gen_command_sources}")
6361

6462
list(TRANSFORM _custom_ops__srcs PREPEND "${EXECUTORCH_ROOT}/")
63+
64+
# TODO: Consider moving xnnpack/threadpool in a separate lib since it's now used
65+
# by custom ops too.
66+
if(NOT EXECUTORCH_BUILD_XNNPACK)
67+
list(
68+
APPEND
69+
_custom_ops__srcs
70+
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../backends/xnnpack/threadpool/threadpool.cpp"
71+
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../backends/xnnpack/threadpool/threadpool_guard.cpp"
72+
)
73+
endif()
74+
6575
add_library(custom_ops ${_custom_ops__srcs})
6676

6777
target_include_directories(custom_ops PUBLIC "${_common_include_directories}")
68-
target_include_directories(custom_ops PRIVATE
69-
"${CMAKE_CURRENT_BINARY_DIR}/../../../../include")
78+
target_include_directories(
79+
custom_ops PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../../../../include")
7080
target_link_libraries(custom_ops PUBLIC ${custom_ops_libs})
7181

7282
target_compile_options(custom_ops PUBLIC ${_common_compile_options}
73-
-DET_USE_THREADPOOL)
83+
-DET_USE_THREADPOOL)
7484

7585
# Build a library for _custom_ops_srcs
7686
#
7787
# custom_ops_lib: Register optimized ops kernels into Executorch runtime
78-
gen_operators_lib(
79-
"custom_ops_lib"
80-
KERNEL_LIBS custom_ops
81-
DEPS executorch)
88+
gen_operators_lib("custom_ops_lib" KERNEL_LIBS custom_ops DEPS executorch)

0 commit comments

Comments
 (0)