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