Skip to content
Merged
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
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,19 @@ if(NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL ""
OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL ""
)
# Use optimized kernels when available.
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
set(_selected_kernel_functions_yaml
${CMAKE_CURRENT_BINARY_DIR}/configurations/merged.yaml
)
set(_selected_kernel_libs "optimized_kernels" "optimized_portable_kernels")
else()
set(_selected_kernel_functions_yaml
${EXECUTORCH_ROOT}/kernels/portable/functions.yaml
)
set(_selected_kernel_libs "portable_kernels")
endif()

gen_selected_ops(
LIB_NAME
"executorch_selected_kernels"
Expand All @@ -945,7 +958,7 @@ if(NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
LIB_NAME
"executorch_selected_kernels"
FUNCTIONS_YAML
${EXECUTORCH_ROOT}/kernels/portable/functions.yaml
${_selected_kernel_functions_yaml}
CUSTOM_OPS_YAML
""
DTYPE_SELECTIVE_BUILD
Expand All @@ -956,13 +969,19 @@ if(NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
LIB_NAME
"executorch_selected_kernels"
KERNEL_LIBS
"portable_kernels"
${_selected_kernel_libs}
DEPS
executorch_core
DTYPE_SELECTIVE_BUILD
"${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD}"
)
list(APPEND _executorch_kernels executorch_selected_kernels)

install(
TARGETS executorch_selected_kernels
EXPORT ExecuTorchTargets
DESTINATION lib
)
else()
# No selective build - link the full library.
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
Expand Down
6 changes: 6 additions & 0 deletions tools/cmake/Codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ function(merge_yaml)
DEPENDS ${GEN_FUNCTIONS_YAML} ${GEN_FALLBACK_YAML}
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
)

# Mark the file as generated to allow it to be referenced from other
# CMakeLists in the project.
set_source_files_properties(
${GEN_OUTPUT_DIR}/merged.yaml PROPERTIES GENERATED TRUE
)
endfunction()

# Append the file list in the variable named `name` in build/build_variables.bzl
Expand Down
Loading