@@ -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 )
@@ -774,11 +779,13 @@ endif()
774
779
if (EXECUTORCH_BUILD_KERNELS_LLM )
775
780
# TODO: move all custom kernels to ${CMAKE_CURRENT_SOURCE_DIR}/kernels/custom
776
781
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/llm/custom_ops )
782
+ list (APPEND _executorch_kernels custom_ops_aot_lib )
777
783
endif ()
778
784
779
785
if (EXECUTORCH_BUILD_KERNELS_QUANTIZED )
780
786
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/quantized )
781
787
executorch_target_link_options_shared_lib (quantized_ops_lib )
788
+ list (APPEND _executorch_kernels quantized_ops_lib )
782
789
endif ()
783
790
784
791
if (EXECUTORCH_BUILD_VULKAN )
@@ -803,6 +810,60 @@ add_library(executorch_extensions INTERFACE)
803
810
add_library (executorch::extensions ALIAS executorch_extensions )
804
811
target_link_libraries (executorch_extensions INTERFACE ${_executorch_extensions} )
805
812
813
+ # A target containing all configured kernels, with selective build, if enabled.
814
+ add_library (executorch_kernels INTERFACE )
815
+ add_library (executorch::kernels ALIAS executorch_kernels )
816
+ if (NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
817
+ OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL ""
818
+ OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL ""
819
+ )
820
+ gen_selected_ops (
821
+ LIB_NAME
822
+ "executorch_selected_kernels"
823
+ OPS_SCHEMA_YAML
824
+ "${EXECUTORCH_SELECT_OPS_LIB} "
825
+ ROOT_OPS
826
+ "${EXECUTORCH_SELECT_OPS_LIST} "
827
+ INCLUDE_ALL_OPS
828
+ FALSE
829
+ OPS_FROM_MODEL
830
+ "${EXECUTORCH_SELECT_OPS_MODEL} "
831
+ DTYPE_SELECTIVE_BUILD
832
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
833
+ )
834
+
835
+ generate_bindings_for_kernels (
836
+ LIB_NAME
837
+ "executorch_selected_kernels"
838
+ FUNCTIONS_YAML
839
+ ${EXECUTORCH_ROOT} /kernels/portable/functions.yaml
840
+ CUSTOM_OPS_YAML
841
+ ""
842
+ DTYPE_SELECTIVE_BUILD
843
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
844
+ )
845
+
846
+ gen_operators_lib (
847
+ LIB_NAME
848
+ "executorch_selected_kernels"
849
+ KERNEL_LIBS
850
+ "portable_kernels"
851
+ DEPS
852
+ executorch_core
853
+ DTYPE_SELECTIVE_BUILD
854
+ "${EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD} "
855
+ )
856
+ list (APPEND _executorch_kernels executorch_selected_kernels )
857
+ else ()
858
+ # No selective build - link the full library.
859
+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED )
860
+ list (APPEND _executorch_kernels optimized_native_cpu_ops_lib )
861
+ else ()
862
+ list (APPEND _executorch_kernels portable_ops_lib )
863
+ endif ()
864
+ endif ()
865
+ target_link_libraries (executorch_kernels INTERFACE ${_executorch_kernels} )
866
+
806
867
if (EXECUTORCH_BUILD_EXECUTOR_RUNNER )
807
868
# Baseline libraries that executor_runner will link against.
808
869
set (_executor_runner_libs executorch extension_evalue_util
0 commit comments