@@ -123,6 +123,8 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
123
123
# Instead please use `find_package(executorch REQUIRED)` in the example
124
124
# directory and add a new executable in the example `CMakeLists.txt`.
125
125
126
+ set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} )
127
+
126
128
if (NOT EXECUTORCH_ENABLE_LOGGING )
127
129
# Avoid pulling in the logging strings, which can be large. Note that this
128
130
# will set the compiler flag for all targets in this directory, and for all
@@ -386,6 +388,9 @@ set(_executorch_backends "")
386
388
# A list of all configured extensions.
387
389
set (_executorch_extensions "" )
388
390
391
+ # A list of all configured kernel libraries.
392
+ set (_executorch_kernels "" )
393
+
389
394
target_link_libraries (executorch_core PRIVATE program_schema )
390
395
if (ANDROID )
391
396
target_link_libraries (executorch_core PUBLIC log )
@@ -778,11 +783,13 @@ endif()
778
783
if (EXECUTORCH_BUILD_KERNELS_LLM )
779
784
# TODO: move all custom kernels to ${CMAKE_CURRENT_SOURCE_DIR}/kernels/custom
780
785
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/llm/custom_ops )
786
+ list (APPEND _executorch_kernels custom_ops_aot_lib )
781
787
endif ()
782
788
783
789
if (EXECUTORCH_BUILD_KERNELS_QUANTIZED )
784
790
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/quantized )
785
791
executorch_target_link_options_shared_lib (quantized_ops_lib )
792
+ list (APPEND _executorch_kernels quantized_ops_lib )
786
793
endif ()
787
794
788
795
if (EXECUTORCH_BUILD_VULKAN )
@@ -809,8 +816,62 @@ add_library(executorch_extensions INTERFACE)
809
816
add_library (executorch::extensions ALIAS executorch_extensions )
810
817
target_link_libraries (executorch_extensions INTERFACE ${_executorch_extensions} )
811
818
819
+ # A target containing all configured kernels, with selective build, if enabled.
820
+ add_library (executorch_kernels INTERFACE )
821
+ add_library (executorch::kernels ALIAS executorch_kernels )
822
+ if (NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
823
+ OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL ""
824
+ OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL ""
825
+ )
826
+ gen_selected_ops (
827
+ LIB_NAME
828
+ "executorch_selected_kernels"
829
+ OPS_SCHEMA_YAML
830
+ "${EXECUTORCH_SELECT_OPS_LIB} "
831
+ ROOT_OPS
832
+ "${EXECUTORCH_SELECT_OPS_LIST} "
833
+ INCLUDE_ALL_OPS
834
+ FALSE
835
+ OPS_FROM_MODEL
836
+ "${EXECUTORCH_SELECT_OPS_MODEL} "
837
+ DTYPE_SELECTIVE_BUILD
838
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
839
+ )
840
+
841
+ generate_bindings_for_kernels (
842
+ LIB_NAME
843
+ "executorch_selected_kernels"
844
+ FUNCTIONS_YAML
845
+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
846
+ CUSTOM_OPS_YAML
847
+ ""
848
+ DTYPE_SELECTIVE_BUILD
849
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
850
+ )
851
+
852
+ gen_operators_lib (
853
+ LIB_NAME
854
+ "executorch_selected_kernels"
855
+ KERNEL_LIBS
856
+ "portable_kernels"
857
+ DEPS
858
+ executorch_core
859
+ DTYPE_SELECTIVE_BUILD
860
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
861
+ )
862
+ list (APPEND _executorch_kernels executorch_selected_kernels )
863
+ else ()
864
+ # No selective build - link the full library.
865
+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED )
866
+ list (APPEND _executorch_kernels optimized_native_cpu_ops_lib )
867
+ else ()
868
+ list (APPEND _executorch_kernels portable_ops_lib )
869
+ endif ()
870
+ endif ()
871
+ target_link_libraries (executorch_kernels INTERFACE ${_executorch_kernels} )
872
+
812
873
install (
813
- TARGETS executorch_backends executorch_extensions
874
+ TARGETS executorch_backends executorch_extensions executorch_kernels
814
875
INCLUDES
815
876
DESTINATION ${_common_include_directories}
816
877
)
0 commit comments