@@ -357,6 +357,9 @@ set(_executorch_backends "")
357
357
# A list of all configured extensions.
358
358
set (_executorch_extensions "" )
359
359
360
+ # A list of all configured kernel libraries.
361
+ set (_executorch_kernels "" )
362
+
360
363
target_link_libraries (executorch_core PRIVATE program_schema)
361
364
if (ANDROID)
362
365
target_link_libraries (executorch_core PUBLIC log )
@@ -706,11 +709,13 @@ endif()
706
709
if (EXECUTORCH_BUILD_KERNELS_LLM)
707
710
# TODO: move all custom kernels to ${CMAKE_CURRENT_SOURCE_DIR}/kernels/custom
708
711
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/llm/custom_ops)
712
+ list (APPEND _executorch_kernels custom_ops_aot_lib)
709
713
endif ()
710
714
711
715
if (EXECUTORCH_BUILD_KERNELS_QUANTIZED)
712
716
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/quantized)
713
717
target_link_options_shared_lib(quantized_ops_lib)
718
+ list (APPEND _executorch_kernels quantized_ops_lib)
714
719
endif ()
715
720
716
721
if (EXECUTORCH_BUILD_VULKAN)
@@ -730,8 +735,62 @@ add_library(executorch_extensions INTERFACE)
730
735
add_library (executorch::extensions ALIAS executorch_extensions)
731
736
target_link_libraries (executorch_extensions INTERFACE ${_executorch_extensions} )
732
737
738
+ # A target containing all configured kernels, with selective build, if enabled.
739
+ add_library (executorch_kernels INTERFACE )
740
+ add_library (executorch::kernels ALIAS executorch_kernels)
741
+ if (NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
742
+ OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL ""
743
+ OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL ""
744
+ )
745
+ gen_selected_ops(
746
+ LIB_NAME
747
+ "executorch_selected_kernels"
748
+ OPS_SCHEMA_YAML
749
+ "${EXECUTORCH_SELECT_OPS_LIB} "
750
+ ROOT_OPS
751
+ "${EXECUTORCH_SELECT_OPS_LIST} "
752
+ INCLUDE_ALL_OPS
753
+ FALSE
754
+ OPS_FROM_MODEL
755
+ "${EXECUTORCH_SELECT_OPS_MODEL} "
756
+ DTYPE_SELECTIVE_BUILD
757
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
758
+ )
759
+
760
+ generate_bindings_for_kernels(
761
+ LIB_NAME
762
+ "executorch_selected_kernels"
763
+ FUNCTIONS_YAML
764
+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
765
+ CUSTOM_OPS_YAML
766
+ ""
767
+ DTYPE_SELECTIVE_BUILD
768
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
769
+ )
770
+
771
+ gen_operators_lib(
772
+ LIB_NAME
773
+ "executorch_selected_kernels"
774
+ KERNEL_LIBS
775
+ "portable_kernels"
776
+ DEPS
777
+ executorch_core
778
+ DTYPE_SELECTIVE_BUILD
779
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
780
+ )
781
+ list (APPEND _executorch_kernels executorch_selected_kernels)
782
+ else ()
783
+ # No selective build - link the full library.
784
+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
785
+ list (APPEND _executorch_kernels optimized_native_cpu_ops_lib)
786
+ else ()
787
+ list (APPEND _executorch_kernels portable_ops_lib)
788
+ endif ()
789
+ endif ()
790
+ target_link_libraries (executorch_kernels INTERFACE ${_executorch_kernels} )
791
+
733
792
install (
734
- TARGETS executorch_backends executorch_extensions
793
+ TARGETS executorch_backends executorch_extensions executorch_kernels
735
794
INCLUDES
736
795
DESTINATION ${_common_include_directories}
737
796
)
0 commit comments