@@ -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 )
@@ -728,8 +733,58 @@ target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})
728
733
add_library (executorch_extensions INTERFACE )
729
734
target_link_libraries (executorch_extensions INTERFACE ${_executorch_extensions} )
730
735
736
+ # A target containing all configured kernels, with selective build, if enabled.
737
+ add_library (executorch_kernels INTERFACE )
738
+ if (NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL "" OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL "" OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL "" )
739
+ gen_selected_ops (
740
+ LIB_NAME
741
+ "executorch_selected_kernels"
742
+ OPS_SCHEMA_YAML
743
+ "${EXECUTORCH_SELECT_OPS_LIB} "
744
+ ROOT_OPS
745
+ "${EXECUTORCH_SELECT_OPS_LIST} "
746
+ INCLUDE_ALL_OPS
747
+ FALSE
748
+ OPS_FROM_MODEL
749
+ "${EXECUTORCH_SELECT_OPS_MODEL} "
750
+ DTYPE_SELECTIVE_BUILD
751
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
752
+ )
753
+
754
+ generate_bindings_for_kernels (
755
+ LIB_NAME
756
+ "executorch_selected_kernels"
757
+ FUNCTIONS_YAML
758
+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
759
+ CUSTOM_OPS_YAML
760
+ ""
761
+ DTYPE_SELECTIVE_BUILD
762
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
763
+ )
764
+
765
+ gen_operators_lib (
766
+ LIB_NAME
767
+ "executorch_selected_kernels"
768
+ KERNEL_LIBS
769
+ "portable_kernels"
770
+ DEPS
771
+ executorch_core
772
+ DTYPE_SELECTIVE_BUILD
773
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
774
+ )
775
+ list (APPEND _executorch_kernels executorch_selected_kernels )
776
+ else ()
777
+ # No selective build - link the full library.
778
+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED )
779
+ list (APPEND _executorch_kernels optimized_native_cpu_ops_lib )
780
+ else ()
781
+ list (APPEND _executorch_kernels portable_ops_lib )
782
+ endif ()
783
+ endif ()
784
+ target_link_libraries (executorch_kernels INTERFACE ${_executorch_kernels} )
785
+
731
786
install (
732
- TARGETS executorch_backends executorch_extensions
787
+ TARGETS executorch_backends executorch_extensions executorch_kernels
733
788
INCLUDES
734
789
DESTINATION ${_common_include_directories}
735
790
)
0 commit comments