From dbbeda305c190fc398f8f7a1b045469421057a7e Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Tue, 6 May 2025 17:25:42 -0700 Subject: [PATCH 1/8] Let's see what will fail --- CMakeLists.txt | 25 ++++++++++++------------- tools/cmake/executorch-config.cmake | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45993721a66..0acb67dd181 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -531,7 +531,7 @@ endif() add_subdirectory(schema) # -# executorch_core: Minimal runtime library +# executorch_core: Primary runtime library # # The bare-minimum runtime library, supporting the Program and Method # interfaces. Does not contain any operators, including primitive ops. Does not @@ -606,18 +606,17 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE) endif() # -# executorch: Primary runtime library with primitive operators. +# prim_ops_lib: primitive operators. # -# Provides the Program and Method interfaces, along with primitive operators. -# Does not contain portable kernels or other full operators. Does not contain -# any backends. +# Provides primitive operators with registration. # -add_library(executorch ${_executorch__srcs}) -target_link_libraries(executorch PRIVATE executorch_core) -target_include_directories(executorch PUBLIC ${_common_include_directories}) -target_compile_definitions(executorch PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) -target_compile_options(executorch PUBLIC ${_common_compile_options}) -target_link_options_shared_lib(executorch) +add_library(prim_ops_lib ${_executorch__srcs}) +target_link_libraries(prim_ops_lib PRIVATE executorch_core) +target_include_directories(prim_ops_lib PUBLIC ${_common_include_directories}) +target_compile_definitions(prim_ops_lib PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) +target_compile_options(prim_ops_lib PUBLIC ${_common_compile_options}) +target_link_options_shared_lib(prim_ops_lib) +add_library(executorch ALIAS prim_ops_lib) # # portable_ops_lib: A library to register core ATen ops using portable kernels, @@ -660,7 +659,7 @@ install(DIRECTORY extension/kernel_util/ DESTINATION include/executorch/extensi install(DIRECTORY extension/tensor/ DESTINATION include/executorch/extension/tensor FILES_MATCHING PATTERN "*.h") install(DIRECTORY extension/threadpool/ DESTINATION include/executorch/extension/threadpool FILES_MATCHING PATTERN "*.h") install( - TARGETS executorch executorch_core + TARGETS executorch_core prim_ops_lib executorch DESTINATION lib INCLUDES DESTINATION ${_common_include_directories} @@ -878,7 +877,7 @@ endif() if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) # Baseline libraries that executor_runner will link against. - set(_executor_runner_libs executorch gflags) + set(_executor_runner_libs executorch_core prim_ops_lib gflags) if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) list(APPEND _executor_runner_libs optimized_native_cpu_ops_lib) diff --git a/tools/cmake/executorch-config.cmake b/tools/cmake/executorch-config.cmake index a8e756fbb77..92a6afd22cb 100644 --- a/tools/cmake/executorch-config.cmake +++ b/tools/cmake/executorch-config.cmake @@ -26,7 +26,7 @@ cmake_minimum_required(VERSION 3.19) set(_root "${CMAKE_CURRENT_LIST_DIR}/../../..") -set(required_lib_list executorch executorch_core portable_kernels) +set(required_lib_list executorch_core prim_ops_lib portable_kernels) set(EXECUTORCH_LIBRARIES) set(EXECUTORCH_INCLUDE_DIRS ${_root}/include ${_root}/include/executorch/runtime/core/portable_type/c10 From 0f9792f0d8a0d7bb92ae837351dc2ecc102aa4c6 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 15:13:06 -0700 Subject: [PATCH 2/8] can't install executorch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0acb67dd181..83030424fa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -659,7 +659,7 @@ install(DIRECTORY extension/kernel_util/ DESTINATION include/executorch/extensi install(DIRECTORY extension/tensor/ DESTINATION include/executorch/extension/tensor FILES_MATCHING PATTERN "*.h") install(DIRECTORY extension/threadpool/ DESTINATION include/executorch/extension/threadpool FILES_MATCHING PATTERN "*.h") install( - TARGETS executorch_core prim_ops_lib executorch + TARGETS executorch_core prim_ops_lib DESTINATION lib INCLUDES DESTINATION ${_common_include_directories} From 94c4b6edb92c5c314e2ff0d95e50a6d8994ca4cc Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 15:18:08 -0700 Subject: [PATCH 3/8] llama demo should work --- examples/models/llama/CMakeLists.txt | 4 ++-- examples/models/llava/CMakeLists.txt | 2 +- tools/cmake/executorch-config.cmake | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/models/llama/CMakeLists.txt b/examples/models/llama/CMakeLists.txt index 4ea735e5717..ef0f4e214ae 100644 --- a/examples/models/llama/CMakeLists.txt +++ b/examples/models/llama/CMakeLists.txt @@ -80,12 +80,12 @@ find_package(gflags REQUIRED) # find `executorch` libraries Same as for gflags set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch) find_package(executorch CONFIG REQUIRED) -target_link_options_shared_lib(executorch) +target_link_options_shared_lib(prim_ops_lib) # llama_runner library add_subdirectory(runner) -set(link_libraries executorch gflags) +set(link_libraries prim_ops_lib gflags) set(_srcs main.cpp) if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) diff --git a/examples/models/llava/CMakeLists.txt b/examples/models/llava/CMakeLists.txt index 232e83d8b0a..7b95cb2ec06 100644 --- a/examples/models/llava/CMakeLists.txt +++ b/examples/models/llava/CMakeLists.txt @@ -89,7 +89,7 @@ endif() # find `executorch` libraries Same as for gflags set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch) find_package(executorch CONFIG REQUIRED) -target_link_options_shared_lib(executorch) +target_link_options_shared_lib(prim_ops_lib) # llava_runner library add_subdirectory(runner) diff --git a/tools/cmake/executorch-config.cmake b/tools/cmake/executorch-config.cmake index 92a6afd22cb..128cb33a7f7 100644 --- a/tools/cmake/executorch-config.cmake +++ b/tools/cmake/executorch-config.cmake @@ -54,7 +54,7 @@ endforeach() # If we reach here, ET required libraries are found. set(EXECUTORCH_FOUND ON) -target_link_libraries(executorch INTERFACE executorch_core) +target_link_libraries(prim_ops_lib INTERFACE executorch_core) if(CMAKE_BUILD_TYPE MATCHES "Debug") set(FLATCCRT_LIB flatccrt_d) From d3eacd7688cbaba3be55067fc2d3e4ca05a1513f Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 15:41:56 -0700 Subject: [PATCH 4/8] Let's see --- CMakeLists.txt | 6 +++--- backends/cadence/CMakeLists.txt | 9 +++++---- backends/cadence/fusion_g3/operators/CMakeLists.txt | 2 +- backends/cadence/hifi/operators/CMakeLists.txt | 4 ++-- backends/cadence/reference/operators/CMakeLists.txt | 4 ++-- backends/openvino/CMakeLists.txt | 8 ++++---- backends/qualcomm/CMakeLists.txt | 3 ++- backends/vulkan/test/CMakeLists.txt | 2 +- backends/vulkan/test/op_tests/CMakeLists.txt | 2 +- backends/xnnpack/CMakeLists.txt | 2 +- devtools/CMakeLists.txt | 4 ++-- examples/apple/mps/CMakeLists.txt | 8 ++++---- examples/arm/CMakeLists.txt | 6 +++--- examples/arm/executor_runner/CMakeLists.txt | 13 +++++++------ examples/cadence/CMakeLists.txt | 2 +- examples/devtools/CMakeLists.txt | 9 +++++---- examples/llm_manual/CMakeLists.txt | 3 ++- examples/mediatek/CMakeLists.txt | 7 ++++--- .../executor_runner/llama_runner/CMakeLists.txt | 2 +- examples/models/llava/CMakeLists.txt | 2 +- examples/models/phi-3-mini/CMakeLists.txt | 2 +- examples/portable/custom_ops/CMakeLists.txt | 8 ++++---- examples/qualcomm/CMakeLists.txt | 4 ++-- examples/selective_build/CMakeLists.txt | 9 ++++----- extension/android/CMakeLists.txt | 5 +++-- extension/apple/CMakeLists.txt | 2 +- extension/llm/runner/test/CMakeLists.txt | 2 +- extension/training/CMakeLists.txt | 3 ++- kernels/prim_ops/test/CMakeLists.txt | 2 +- runtime/kernel/test/CMakeLists.txt | 6 +++--- test/CMakeLists.txt | 8 ++++---- 31 files changed, 78 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83030424fa1..99c0aff8380 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -616,7 +616,6 @@ target_include_directories(prim_ops_lib PUBLIC ${_common_include_directories}) target_compile_definitions(prim_ops_lib PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) target_compile_options(prim_ops_lib PUBLIC ${_common_compile_options}) target_link_options_shared_lib(prim_ops_lib) -add_library(executorch ALIAS prim_ops_lib) # # portable_ops_lib: A library to register core ATen ops using portable kernels, @@ -785,8 +784,9 @@ if(EXECUTORCH_BUILD_PYBIND) ${TORCH_PYTHON_LIBRARY} bundled_program etdump - executorch + executorch_core extension_data_loader + prim_ops_lib util torch ) @@ -838,7 +838,7 @@ if(EXECUTORCH_BUILD_PYBIND) target_compile_definitions(util PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) target_compile_options(util PUBLIC ${_pybind_compile_options}) - target_link_libraries(util PRIVATE torch c10 executorch extension_tensor) + target_link_libraries(util PRIVATE torch c10 executorch_core extension_tensor) # pybind portable_lib pybind11_add_module(portable_lib SHARED extension/pybindings/pybindings.cpp) diff --git a/backends/cadence/CMakeLists.txt b/backends/cadence/CMakeLists.txt index f8bb42cba50..161d8ffceec 100644 --- a/backends/cadence/CMakeLists.txt +++ b/backends/cadence/CMakeLists.txt @@ -39,10 +39,10 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER) # Find prebuilt libraries. executorch package should contain portable_ops_lib, # etdump, bundled_program. find_package(executorch CONFIG REQUIRED) - target_link_options_shared_lib(executorch) + target_link_options_shared_lib(prim_ops_lib) target_link_options_shared_lib(portable_ops_lib) - target_include_directories(executorch INTERFACE ${_common_include_directories}) + target_include_directories(executorch_core INTERFACE ${_common_include_directories}) find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party @@ -51,7 +51,7 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER) add_executable(cadence_runner ${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp ) - target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) + target_compile_options(executorch_core INTERFACE -DET_EVENT_TRACER_ENABLED) target_include_directories( etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include @@ -65,7 +65,8 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER) target_link_libraries( cadence_runner - executorch + executorch_core + prim_ops_lib gflags etdump extension_data_loader diff --git a/backends/cadence/fusion_g3/operators/CMakeLists.txt b/backends/cadence/fusion_g3/operators/CMakeLists.txt index ec3220179a6..fd0c67374b8 100644 --- a/backends/cadence/fusion_g3/operators/CMakeLists.txt +++ b/backends/cadence/fusion_g3/operators/CMakeLists.txt @@ -69,7 +69,7 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/pattern/unary_ufunc_realhbbf16_to_floathbf16.cpp" ) add_library(aten_ops_cadence ${_aten_ops__srcs}) -target_link_libraries(aten_ops_cadence PUBLIC executorch) +target_link_libraries(aten_ops_cadence PUBLIC executorch_core) target_link_libraries(aten_ops_cadence PRIVATE xa_nnlib) # Let files say "include ". diff --git a/backends/cadence/hifi/operators/CMakeLists.txt b/backends/cadence/hifi/operators/CMakeLists.txt index 3867e0f44f2..f406eb9cf65 100644 --- a/backends/cadence/hifi/operators/CMakeLists.txt +++ b/backends/cadence/hifi/operators/CMakeLists.txt @@ -65,7 +65,7 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/delinearize_index.cpp" ) add_library(aten_ops_cadence ${_aten_ops__srcs}) -target_link_libraries(aten_ops_cadence PUBLIC executorch) +target_link_libraries(aten_ops_cadence PUBLIC executorch_core) target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels) # Let files say "include ". @@ -88,7 +88,7 @@ target_include_directories( ${_common_include_directories} ) -target_link_libraries(custom_ops PUBLIC executorch) +target_link_libraries(custom_ops PUBLIC executorch_core) target_link_libraries(custom_ops PRIVATE cadence_kernels) # Generate C++ bindings to register kernels into both PyTorch (for AOT) and diff --git a/backends/cadence/reference/operators/CMakeLists.txt b/backends/cadence/reference/operators/CMakeLists.txt index e0a10c6fa36..4b05f5f9158 100644 --- a/backends/cadence/reference/operators/CMakeLists.txt +++ b/backends/cadence/reference/operators/CMakeLists.txt @@ -67,7 +67,7 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/select_copy_util.cpp" ) add_library(aten_ops_cadence ${_aten_ops__srcs}) -target_link_libraries(aten_ops_cadence PUBLIC executorch) +target_link_libraries(aten_ops_cadence PUBLIC executorch_core) target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels) # Let files say "include ". @@ -98,7 +98,7 @@ target_include_directories( ${_common_include_directories} ) -target_link_libraries(custom_ops PUBLIC executorch) +target_link_libraries(custom_ops PUBLIC executorch_core) target_link_libraries(custom_ops PRIVATE cadence_kernels) # Generate C++ bindings to register kernels into both PyTorch (for AOT) and diff --git a/backends/openvino/CMakeLists.txt b/backends/openvino/CMakeLists.txt index 8d07cd9a366..b9082f8ffc1 100644 --- a/backends/openvino/CMakeLists.txt +++ b/backends/openvino/CMakeLists.txt @@ -50,8 +50,8 @@ target_link_options_shared_lib(openvino_backend) if(EXECUTORCH_BUILD_OPENVINO_EXECUTOR_RUNNER) # Build executor runner binary for openvino backend - list(APPEND openvino_executor_runner_libs openvino_backend executorch) - + list(APPEND openvino_executor_runner_libs openvino_backend executorch_core prim_ops_lib) + set(_openvino_executor_runner__srcs ${EXECUTORCH_ROOT}/examples/portable/executor_runner/executor_runner.cpp ${EXECUTORCH_ROOT}/extension/data_loader/file_data_loader.cpp @@ -60,9 +60,9 @@ if(EXECUTORCH_BUILD_OPENVINO_EXECUTOR_RUNNER) ${EXECUTORCH_ROOT}/extension/runner_util/inputs_portable.cpp ) add_executable(openvino_executor_runner ${_openvino_executor_runner__srcs}) - + list(APPEND openvino_executor_runner_libs) - + target_link_libraries( openvino_executor_runner gflags portable_ops_lib ${openvino_executor_runner_libs} ) diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index 1b7c8891a4e..9d88e9df7fa 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -242,7 +242,8 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") qnn_schema qnn_manager qnn_executorch_header - executorch + executorch_core + prim_ops_lib qcir_utils extension_tensor ) diff --git a/backends/vulkan/test/CMakeLists.txt b/backends/vulkan/test/CMakeLists.txt index 95f0179f367..0b3f22875ad 100644 --- a/backends/vulkan/test/CMakeLists.txt +++ b/backends/vulkan/test/CMakeLists.txt @@ -82,7 +82,7 @@ if(TARGET vulkan_backend) ) target_include_directories(vulkan_compute_api_test PRIVATE ${COMMON_INCLUDES}) target_link_libraries( - vulkan_compute_api_test PRIVATE GTest::gtest_main vulkan_backend executorch + vulkan_compute_api_test PRIVATE GTest::gtest_main vulkan_backend executorch_core test_shaderlib ) target_compile_options(vulkan_compute_api_test PRIVATE ${VULKAN_CXX_FLAGS}) diff --git a/backends/vulkan/test/op_tests/CMakeLists.txt b/backends/vulkan/test/op_tests/CMakeLists.txt index 584719d5c28..a34d3f297f6 100644 --- a/backends/vulkan/test/op_tests/CMakeLists.txt +++ b/backends/vulkan/test/op_tests/CMakeLists.txt @@ -81,7 +81,7 @@ function(vulkan_op_test test_name test_src) ${test_name} PRIVATE GTest::gtest_main vulkan_backend - executorch + executorch_core ${LIB_TORCH} ${LIB_TORCH_CPU} ${LIB_C10} diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 250190a5712..a018cce031e 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -150,7 +150,7 @@ if(EXECUTORCH_BUILD_KERNELS_QUANTIZED) list(APPEND xnn_executor_runner_libs quantized_ops_lib) endif() -list(APPEND xnn_executor_runner_libs xnnpack_backend executorch) +list(APPEND xnn_executor_runner_libs xnnpack_backend executorch_core prim_ops_lib) # ios can only build library but not binary if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") diff --git a/devtools/CMakeLists.txt b/devtools/CMakeLists.txt index 9dd38d3678e..4e08a9ab428 100644 --- a/devtools/CMakeLists.txt +++ b/devtools/CMakeLists.txt @@ -193,7 +193,7 @@ add_library( target_link_libraries( etdump PUBLIC etdump_schema flatccrt - PRIVATE executorch + PRIVATE executorch_core ) add_custom_command( @@ -213,7 +213,7 @@ add_library( bundled_program ${CMAKE_CURRENT_SOURCE_DIR}/bundled_program/bundled_program.cpp ) -target_link_libraries(bundled_program executorch bundled_program_schema) +target_link_libraries(bundled_program executorch_core bundled_program_schema) set_target_properties(bundled_program PROPERTIES LINKER_LANGUAGE CXX) target_include_directories( diff --git a/examples/apple/mps/CMakeLists.txt b/examples/apple/mps/CMakeLists.txt index 66583592844..49f95974b72 100644 --- a/examples/apple/mps/CMakeLists.txt +++ b/examples/apple/mps/CMakeLists.txt @@ -43,8 +43,8 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..) # Find prebuilt libraries. executorch package should contain portable_ops_lib, # etdump, bundled_program. find_package(executorch CONFIG REQUIRED) -target_include_directories(executorch INTERFACE ${_common_include_directories}) -target_compile_options(executorch INTERFACE ${_common_compile_options}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) +target_compile_options(executorch_core INTERFACE ${_common_compile_options}) find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party @@ -67,7 +67,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") ) gen_operators_lib( LIB_NAME "mps_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS - executorch + executorch_core ) set(mps_executor_runner_libs @@ -110,7 +110,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") target_link_libraries( mps_executor_runner bundled_program - executorch + executorch_core gflags etdump ${FLATCC_LIB} diff --git a/examples/arm/CMakeLists.txt b/examples/arm/CMakeLists.txt index 4bae20d2c1f..b6b79ba305d 100644 --- a/examples/arm/CMakeLists.txt +++ b/examples/arm/CMakeLists.txt @@ -33,7 +33,7 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC) set(_common_include_directories ${EXECUTORCH_ROOT}/..) find_package(executorch CONFIG REQUIRED HINTS ${CMAKE_INSTALL_PREFIX}) -target_include_directories(executorch INTERFACE ${_common_include_directories}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake) @@ -55,10 +55,10 @@ generate_bindings_for_kernels( ${EXECUTORCH_ROOT}/kernels/portable/functions.yaml ) gen_operators_lib( - LIB_NAME "arm_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch + LIB_NAME "arm_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch_core ) if(EXECUTORCH_ENABLE_EVENT_TRACER) - target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) + target_compile_options(executorch_core INTERFACE -DET_EVENT_TRACER_ENABLED) target_compile_options(portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED) endif() diff --git a/examples/arm/executor_runner/CMakeLists.txt b/examples/arm/executor_runner/CMakeLists.txt index 63cdcc45aad..e7ca085b165 100644 --- a/examples/arm/executor_runner/CMakeLists.txt +++ b/examples/arm/executor_runner/CMakeLists.txt @@ -460,10 +460,10 @@ endif() # Dependencies from the ExecuTorch build -add_library(executorch STATIC IMPORTED) +add_library(prim_ops_lib STATIC IMPORTED) set_property( - TARGET executorch PROPERTY IMPORTED_LOCATION - "${ET_BUILD_DIR_PATH}/libexecutorch.a" + TARGET prim_ops_lib PROPERTY IMPORTED_LOCATION + "${ET_BUILD_DIR_PATH}/libprim_ops_lib.a" ) add_library(executorch_core STATIC IMPORTED) @@ -471,7 +471,7 @@ set_property( TARGET executorch_core PROPERTY IMPORTED_LOCATION "${ET_BUILD_DIR_PATH}/libexecutorch_core.a" ) -target_link_libraries(executorch INTERFACE executorch_core) +target_link_libraries(prim_ops_lib INTERFACE executorch_core) add_library(executorch_delegate_ethos_u STATIC IMPORTED) set_property( @@ -543,13 +543,14 @@ set(arm_executor_runner_link) list(APPEND arm_executor_runner_link extension_runner_util ethosu_target_init - executorch + executorch_core "-Wl,--whole-archive" executorch_delegate_ethos_u quantized_ops_lib portable_ops_lib quantized_kernels portable_kernels + prim_ops_lib "-Wl,--no-whole-archive" -Xlinker -Map=arm_executor_runner.map ) @@ -643,4 +644,4 @@ if(SEMIHOSTING) ${ETHOS_SDK_PATH}/core_platform/targets/${TARGET_BOARD}/retarget.c PROPERTIES HEADER_FILE_ONLY TRUE ) -endif() \ No newline at end of file +endif() diff --git a/examples/cadence/CMakeLists.txt b/examples/cadence/CMakeLists.txt index 757009bd4df..d782de3ed9c 100644 --- a/examples/cadence/CMakeLists.txt +++ b/examples/cadence/CMakeLists.txt @@ -123,7 +123,7 @@ target_link_options( ) target_link_libraries( cadence_executorch_example dsp_mu_polling_libs cadence_ops_lib - extension_runner_util executorch + extension_runner_util executorch_core prim_ops_lib ) add_custom_command( diff --git a/examples/devtools/CMakeLists.txt b/examples/devtools/CMakeLists.txt index 74cbf5e78e6..d9e620b5a2b 100644 --- a/examples/devtools/CMakeLists.txt +++ b/examples/devtools/CMakeLists.txt @@ -37,17 +37,17 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..) # Find prebuilt libraries. executorch package should contain portable_ops_lib, # etdump, bundled_program. find_package(executorch CONFIG REQUIRED) -target_link_options_shared_lib(executorch) +target_link_options_shared_lib(prim_ops_lib) target_link_options_shared_lib(portable_ops_lib) -target_include_directories(executorch INTERFACE ${_common_include_directories}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party ) add_executable(example_runner example_runner/example_runner.cpp) -target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) +target_compile_options(executorch_core INTERFACE -DET_EVENT_TRACER_ENABLED) target_include_directories( etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include @@ -55,7 +55,7 @@ target_include_directories( ) target_link_libraries( example_runner - executorch + executorch_core gflags etdump extension_data_loader @@ -63,6 +63,7 @@ target_link_libraries( flatccrt portable_ops_lib portable_kernels + prim_ops_lib ) if(EXECUTORCH_BUILD_COREML) diff --git a/examples/llm_manual/CMakeLists.txt b/examples/llm_manual/CMakeLists.txt index 1283eb548ea..f2d078d873c 100644 --- a/examples/llm_manual/CMakeLists.txt +++ b/examples/llm_manual/CMakeLists.txt @@ -26,7 +26,8 @@ add_subdirectory( add_executable(nanogpt_runner main.cpp) target_link_libraries( nanogpt_runner - PRIVATE executorch + PRIVATE executorch_core + prim_ops_lib extension_module_static # Provides the Module class extension_tensor # Provides the TensorPtr class optimized_native_cpu_ops_lib # Provides baseline cross-platform diff --git a/examples/mediatek/CMakeLists.txt b/examples/mediatek/CMakeLists.txt index 8d33244fdfa..863832e142b 100644 --- a/examples/mediatek/CMakeLists.txt +++ b/examples/mediatek/CMakeLists.txt @@ -43,7 +43,7 @@ include(${EXECUTORCH_SRCS_FILE}) # Find prebuilt libraries. executorch package should contain portable_ops_lib, # etdump, bundled_program. find_package(executorch CONFIG REQUIRED) -target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) +target_compile_options(executorch_core INTERFACE -DET_EVENT_TRACER_ENABLED) find_package(gflags REQUIRED) link_directories(${EXECUTORCH_ROOT}/cmake-android-out/lib) @@ -70,7 +70,7 @@ if(${ANDROID}) ) target_link_libraries( - mtk_executor_runner ${_executor_runner_libs} executorch neuron_backend + mtk_executor_runner ${_executor_runner_libs} executorch_core prim_ops_lib neuron_backend gflags ) target_compile_options(mtk_executor_runner PUBLIC ${_common_compile_options}) @@ -104,7 +104,8 @@ if(${ANDROID}) target_link_libraries(mtk_oss_executor_runner ${_executor_runner_libs} - executorch + executorch_core + prim_ops_lib neuron_backend gflags ) diff --git a/examples/mediatek/executor_runner/llama_runner/CMakeLists.txt b/examples/mediatek/executor_runner/llama_runner/CMakeLists.txt index 9d27e685f3a..348954b82f2 100644 --- a/examples/mediatek/executor_runner/llama_runner/CMakeLists.txt +++ b/examples/mediatek/executor_runner/llama_runner/CMakeLists.txt @@ -20,7 +20,7 @@ target_sources( llm_helper/token_embedding.cpp ) -target_link_libraries(llm_helper PRIVATE executorch) +target_link_libraries(llm_helper PRIVATE executorch_core prim_ops) target_include_directories( llm_helper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} llm_helper/include ) diff --git a/examples/models/llava/CMakeLists.txt b/examples/models/llava/CMakeLists.txt index 7b95cb2ec06..45003c6636c 100644 --- a/examples/models/llava/CMakeLists.txt +++ b/examples/models/llava/CMakeLists.txt @@ -94,7 +94,7 @@ target_link_options_shared_lib(prim_ops_lib) # llava_runner library add_subdirectory(runner) -set(LINK_LIBS executorch gflags) +set(LINK_LIBS executorch_core prim_ops_lib gflags) if(NOT LLAVA_RUNNER_NO_TORCH_DUMMY_IMAGE) list(APPEND LINK_LIBS torch) endif() diff --git a/examples/models/phi-3-mini/CMakeLists.txt b/examples/models/phi-3-mini/CMakeLists.txt index 5e9cad0d3de..79db34892b9 100644 --- a/examples/models/phi-3-mini/CMakeLists.txt +++ b/examples/models/phi-3-mini/CMakeLists.txt @@ -49,6 +49,6 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../extension/llm/tokenizers/include ) target_link_libraries( - phi_3_mini_runner PRIVATE executorch extension_module_static extension_tensor + phi_3_mini_runner PRIVATE prim_ops_lib extension_module_static extension_tensor optimized_native_cpu_ops_lib xnnpack_backend gflags ) diff --git a/examples/portable/custom_ops/CMakeLists.txt b/examples/portable/custom_ops/CMakeLists.txt index 5a9a9a11fe6..aaef5391308 100644 --- a/examples/portable/custom_ops/CMakeLists.txt +++ b/examples/portable/custom_ops/CMakeLists.txt @@ -44,7 +44,7 @@ find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party ) -target_include_directories(executorch INTERFACE ${_common_include_directories}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) # ------------------------------ OPTIONS BEGIN ------------------------------- # Option to register custom operator `my_ops::mul3` or `my_ops::mul4` or no @@ -112,18 +112,18 @@ elseif(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 2) endif() add_library(custom_kernels ${kernel_sources}) -target_link_libraries(custom_kernels PRIVATE executorch) +target_link_libraries(custom_kernels PRIVATE executorch_core) target_compile_options(custom_kernels PUBLIC ${_common_compile_options}) gen_operators_lib( - LIB_NAME "custom_ops_lib" KERNEL_LIBS custom_kernels DEPS executorch + LIB_NAME "custom_ops_lib" KERNEL_LIBS custom_kernels DEPS executorch_core ) list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") add_executable(custom_ops_executor_runner ${_executor_runner__srcs}) target_link_libraries( - custom_ops_executor_runner custom_ops_lib executorch gflags + custom_ops_executor_runner custom_ops_lib prim_ops_lib gflags ) target_compile_options( custom_ops_executor_runner PUBLIC ${_common_compile_options} diff --git a/examples/qualcomm/CMakeLists.txt b/examples/qualcomm/CMakeLists.txt index 4f338a23044..055b6a42ccc 100644 --- a/examples/qualcomm/CMakeLists.txt +++ b/examples/qualcomm/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # Find prebuilt libraries. executorch package should contain portable_ops_lib, # etdump, bundled_program. find_package(executorch CONFIG REQUIRED) -target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) +target_compile_options(executorch_core INTERFACE -DET_EVENT_TRACER_ENABLED) find_package(gflags REQUIRED) set(_common_compile_options -Wno-deprecated-declarations -fPIC) @@ -57,7 +57,7 @@ generate_bindings_for_kernels( ${EXECUTORCH_ROOT}/kernels/portable/functions.yaml ) gen_operators_lib( - LIB_NAME "full_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch + LIB_NAME "full_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch_core ) target_compile_options( full_portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED diff --git a/examples/selective_build/CMakeLists.txt b/examples/selective_build/CMakeLists.txt index db570bb98c3..fc059c2cc68 100644 --- a/examples/selective_build/CMakeLists.txt +++ b/examples/selective_build/CMakeLists.txt @@ -43,7 +43,7 @@ find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party ) -target_include_directories(executorch INTERFACE ${_common_include_directories}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) # ------------------------------ OPTIONS BEGIN ------------------------------- @@ -91,7 +91,7 @@ if(EXECUTORCH_SELECT_OPS_YAML) # custom_kernels: C++ kernel implementations of custom ops # add_library(custom_kernels ${kernel_sources}) - target_link_libraries(custom_kernels PRIVATE executorch) + target_link_libraries(custom_kernels PRIVATE executorch_core) target_compile_options(custom_kernels PUBLIC ${_common_compile_options}) list(APPEND _kernel_lib custom_kernels) @@ -117,7 +117,7 @@ generate_bindings_for_kernels( ) gen_operators_lib( - LIB_NAME "select_build_lib" KERNEL_LIBS ${_kernel_lib} DEPS executorch + LIB_NAME "select_build_lib" KERNEL_LIBS ${_kernel_lib} DEPS executorch_core ) list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") @@ -131,10 +131,9 @@ if(CMAKE_BUILD_TYPE EQUAL "Release") target_link_options(selective_build_test PRIVATE "LINKER:--gc-sections") endif() target_link_libraries( - selective_build_test PRIVATE executorch gflags select_build_lib + selective_build_test PRIVATE executorch_core gflags select_build_lib ) target_link_options_shared_lib(select_build_lib) -target_link_options_shared_lib(executorch) target_compile_options(selective_build_test PUBLIC ${_common_compile_options}) # Print all summary diff --git a/extension/android/CMakeLists.txt b/extension/android/CMakeLists.txt index b2f7b8d9f47..28c69035974 100644 --- a/extension/android/CMakeLists.txt +++ b/extension/android/CMakeLists.txt @@ -62,7 +62,7 @@ set_target_properties(fbjni PROPERTIES set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch) find_package(executorch CONFIG REQUIRED) -target_link_options_shared_lib(executorch) +target_link_options_shared_lib(prim_ops_lib) add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp) @@ -70,7 +70,7 @@ set(link_libraries) list( APPEND link_libraries - executorch + executorch_core extension_data_loader extension_flat_tensor extension_module @@ -78,6 +78,7 @@ list( extension_tensor extension_threadpool fbjni + prim_ops_lib ) if(TARGET optimized_native_cpu_ops_lib) diff --git a/extension/apple/CMakeLists.txt b/extension/apple/CMakeLists.txt index b7abfbe11a2..7ce02b6a3b5 100644 --- a/extension/apple/CMakeLists.txt +++ b/extension/apple/CMakeLists.txt @@ -40,7 +40,7 @@ target_include_directories(extension_apple find_library(FOUNDATION_FRAMEWORK Foundation) target_link_libraries(extension_apple - PRIVATE executorch ${FOUNDATION_FRAMEWORK} + PRIVATE executorch_core prim_ops_lib ${FOUNDATION_FRAMEWORK} ) target_compile_options(extension_apple PUBLIC ${_common_compile_options}) diff --git a/extension/llm/runner/test/CMakeLists.txt b/extension/llm/runner/test/CMakeLists.txt index b17a318a080..3c386622988 100644 --- a/extension/llm/runner/test/CMakeLists.txt +++ b/extension/llm/runner/test/CMakeLists.txt @@ -24,5 +24,5 @@ et_cxx_test( SOURCES ${_test_srcs} EXTRA_LIBS - executorch + executorch_core ) diff --git a/extension/training/CMakeLists.txt b/extension/training/CMakeLists.txt index ee496a7e577..7f44afacdd5 100644 --- a/extension/training/CMakeLists.txt +++ b/extension/training/CMakeLists.txt @@ -44,10 +44,11 @@ target_compile_options(train_xor PUBLIC ${_common_compile_options}) set(_pybind_training_dep_libs ${TORCH_PYTHON_LIBRARY} etdump - executorch + executorch_core util torch extension_training + prim_ops_lib ) if(EXECUTORCH_BUILD_XNNPACK) diff --git a/kernels/prim_ops/test/CMakeLists.txt b/kernels/prim_ops/test/CMakeLists.txt index c92daada12b..7a8bc00ea47 100644 --- a/kernels/prim_ops/test/CMakeLists.txt +++ b/kernels/prim_ops/test/CMakeLists.txt @@ -20,4 +20,4 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake) set(_test_srcs prim_ops_test.cpp) -et_cxx_test(kernels_prim_ops_test SOURCES ${_test_srcs} EXTRA_LIBS executorch) +et_cxx_test(kernels_prim_ops_test SOURCES ${_test_srcs} EXTRA_LIBS prim_ops_lib) diff --git a/runtime/kernel/test/CMakeLists.txt b/runtime/kernel/test/CMakeLists.txt index 9ff47fbefd5..5a9c4f0febf 100644 --- a/runtime/kernel/test/CMakeLists.txt +++ b/runtime/kernel/test/CMakeLists.txt @@ -20,7 +20,7 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake) add_executable(operator_registry_test operator_registry_test.cpp) target_link_libraries( - operator_registry_test GTest::gtest GTest::gtest_main GTest::gmock executorch + operator_registry_test GTest::gtest GTest::gtest_main GTest::gmock executorch_core ) target_include_directories(operator_registry_test PRIVATE ${EXECUTORCH_ROOT}/..) add_test(operator_registry_test operator_registry_test) @@ -28,7 +28,7 @@ add_test(operator_registry_test operator_registry_test) add_executable(kernel_runtime_context_test kernel_runtime_context_test.cpp) target_link_libraries( kernel_runtime_context_test GTest::gtest GTest::gtest_main GTest::gmock - executorch + executorch_core ) target_include_directories( kernel_runtime_context_test PRIVATE ${EXECUTORCH_ROOT}/.. @@ -47,7 +47,7 @@ add_executable( ) target_link_libraries( operator_registry_max_kernel_num_test GTest::gtest GTest::gtest_main - GTest::gmock executorch + GTest::gmock executorch_core ) target_compile_definitions( operator_registry_max_kernel_num_test PRIVATE "-DMAX_KERNEL_NUM=1" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 04e18f55a9e..bdda18825f3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,7 +30,7 @@ find_package(executorch CONFIG REQUIRED HINTS ${CMAKE_INSTALL_PREFIX}) # Let files say "include ". set(_common_include_directories ${EXECUTORCH_ROOT}/..) -target_include_directories(executorch INTERFACE ${_common_include_directories}) +target_include_directories(executorch_core INTERFACE ${_common_include_directories}) # # The `__srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}. @@ -51,7 +51,7 @@ list(TRANSFORM _size_test__srcs PREPEND "${EXECUTORCH_ROOT}/") # TODO(larryliu0820): Add EXECUTORCH_BUILD_EXECUTABLES to not build executable # when we cross compile to ios add_executable(size_test ${_size_test__srcs}) -target_link_libraries(size_test executorch) +target_link_libraries(size_test executorch_core) if(CMAKE_BUILD_TYPE EQUAL "Release") target_link_options(size_test PRIVATE "LINKER:--gc-sections") endif() @@ -62,7 +62,7 @@ endif() add_executable(size_test_all_ops ${_size_test__srcs}) target_link_options_shared_lib(portable_ops_lib) target_link_libraries( - size_test_all_ops executorch portable_ops_lib portable_kernels + size_test_all_ops prim_ops_lib portable_ops_lib portable_kernels ) if(CMAKE_BUILD_TYPE EQUAL "Release") target_link_options(size_test_all_ops PRIVATE "LINKER:--gc-sections") @@ -75,7 +75,7 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) add_executable(size_test_all_optimized_ops ${_size_test__srcs}) target_link_options_shared_lib(optimized_native_cpu_ops_lib) target_link_libraries( - size_test_all_optimized_ops executorch optimized_native_cpu_ops_lib) + size_test_all_optimized_ops prim_ops_lib optimized_native_cpu_ops_lib) if(CMAKE_BUILD_TYPE EQUAL "Release") target_link_options(size_test_all_optimized_ops PRIVATE "LINKER:--gc-sections") endif() From 74c2253db647f8ea7102a99d6166a6fb62637e58 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 16:10:28 -0700 Subject: [PATCH 5/8] Update libexecutorch.a --- .ci/scripts/test_llama.sh | 2 +- .ci/scripts/utils.sh | 2 +- backends/apple/coreml/scripts/build_tests.sh | 4 ++-- backends/cadence/runtime/executor_main.sh | 2 +- docs/source/tutorial-arm-ethos-u.md | 3 ++- docs/source/using-executorch-building-from-source.md | 4 ++-- examples/apple/mps/test_mps.sh | 2 +- examples/devtools/test_example_runner.sh | 2 +- examples/qualcomm/test_qualcomm.sh | 2 +- scripts/build_apple_frameworks.sh | 2 +- test/build_optimized_size_test.sh | 2 +- test/build_size_test.sh | 2 +- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.ci/scripts/test_llama.sh b/.ci/scripts/test_llama.sh index 8e8ba898c48..e874e32fed3 100644 --- a/.ci/scripts/test_llama.sh +++ b/.ci/scripts/test_llama.sh @@ -150,7 +150,7 @@ fi which "${PYTHON_EXECUTABLE}" cmake_install_executorch_libraries() { - echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a" + echo "Installing libprim_ops_lib.a, libextension_module.so, libportable_ops_lib.a" rm -rf cmake-out retry cmake \ -DCMAKE_INSTALL_PREFIX=cmake-out \ diff --git a/.ci/scripts/utils.sh b/.ci/scripts/utils.sh index f2286cd40b9..2b7baf5941d 100644 --- a/.ci/scripts/utils.sh +++ b/.ci/scripts/utils.sh @@ -156,7 +156,7 @@ build_executorch_runner() { } cmake_install_executorch_lib() { - echo "Installing libexecutorch.a and libportable_kernels.a" + echo "Installing libprim_ops_lib.a and libportable_kernels.a" clean_executorch_install_folders retry cmake -DBUCK2="$BUCK" \ -DCMAKE_INSTALL_PREFIX=cmake-out \ diff --git a/backends/apple/coreml/scripts/build_tests.sh b/backends/apple/coreml/scripts/build_tests.sh index 890385d5e24..b3b93d04418 100755 --- a/backends/apple/coreml/scripts/build_tests.sh +++ b/backends/apple/coreml/scripts/build_tests.sh @@ -52,12 +52,12 @@ cmake "$PROTOBUF_DIR_PATH/cmake" -B"$CMAKE_PROTOBUF_BUILD_DIR_PATH" \ -DCMAKE_MACOSX_BUNDLE=OFF \ -DCMAKE_CXX_STANDARD=17 -cmake --build "$CMAKE_PROTOBUF_BUILD_DIR_PATH" -j9 -t libprotobuf-lite +cmake --build "$CMAKE_PROTOBUF_BUILDb_DIR_PATH" -j9 -t libprotobuf-lite # Copy required libraries echo "ExecuTorch: Copying libraries" mkdir "$LIBRARIES_DIR_PATH" -cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch.a" "$LIBRARIES_DIR_PATH" +cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libprim_ops_lib.a" "$LIBRARIES_DIR_PATH" cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch_core.a" "$LIBRARIES_DIR_PATH" cp -f "$CMAKE_PROTOBUF_BUILD_DIR_PATH/libprotobuf-lite.a" "$LIBRARIES_DIR_PATH" diff --git a/backends/cadence/runtime/executor_main.sh b/backends/cadence/runtime/executor_main.sh index 7d6cba09b87..93d3e6e3f65 100644 --- a/backends/cadence/runtime/executor_main.sh +++ b/backends/cadence/runtime/executor_main.sh @@ -15,7 +15,7 @@ set -e source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh" cmake_install_executorch_devtools_lib() { - echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a" + echo "Installing libprim_ops_lib.a, libportable_kernels.a, libetdump.a, libbundled_program.a" rm -rf cmake-out retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ diff --git a/docs/source/tutorial-arm-ethos-u.md b/docs/source/tutorial-arm-ethos-u.md index 96f452eeef3..8c6435d42f2 100644 --- a/docs/source/tutorial-arm-ethos-u.md +++ b/docs/source/tutorial-arm-ethos-u.md @@ -288,7 +288,8 @@ ExecuTorch's CMake build system produces a set of build pieces which are critica [This](using-executorch-building-from-source.md) document provides a detailed overview of each individual build piece. For running either variant of the `.pte` file, you will need a core set of libraries. Here is a list, -- `libexecutorch.a` +- `libexecutorch_core.a` +- `libprim_ops_lib.a` - `libportable_kernels.a` - `libportable_ops_lib.a` diff --git a/docs/source/using-executorch-building-from-source.md b/docs/source/using-executorch-building-from-source.md index e2657e69b55..a4013ac7720 100644 --- a/docs/source/using-executorch-building-from-source.md +++ b/docs/source/using-executorch-building-from-source.md @@ -121,8 +121,8 @@ Or alternatively, [install conda on your machine](https://conda.io/projects/cond ExecuTorch's CMake build system covers the pieces of the runtime that are likely to be useful to embedded systems users. -- `libexecutorch.a`: The core of the ExecuTorch runtime. Does not contain any - operator/kernel definitions or backend definitions. +- `libexecutorch_core.a`: The core of the ExecuTorch runtime. Does not contain any +- `libprim_ops_lib.a`: The implementations and registration of prim ops. - `libportable_kernels.a`: The implementations of ATen-compatible operators, following the signatures in `//kernels/portable/functions.yaml`. - `libportable_kernels_bindings.a`: Generated code that registers the contents diff --git a/examples/apple/mps/test_mps.sh b/examples/apple/mps/test_mps.sh index 555161dd3f7..60ea355e998 100755 --- a/examples/apple/mps/test_mps.sh +++ b/examples/apple/mps/test_mps.sh @@ -12,7 +12,7 @@ set -e # shellcheck source=/dev/null source "$(dirname "${BASH_SOURCE[0]}")/../../../.ci/scripts/utils.sh" cmake_install_executorch_devtools_lib() { - echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a" + echo "Installing libprim_ops_lib.a, libportable_kernels.a, libetdump.a, libbundled_program.a" rm -rf cmake-out retry cmake -DBUCK2="$BUCK" \ diff --git a/examples/devtools/test_example_runner.sh b/examples/devtools/test_example_runner.sh index b16d4f3e04a..af997042181 100644 --- a/examples/devtools/test_example_runner.sh +++ b/examples/devtools/test_example_runner.sh @@ -15,7 +15,7 @@ set -e source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh" cmake_install_executorch_devtools_lib() { - echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a" + echo "Installing libprim_ops_lib.a, libportable_kernels.a, libetdump.a, libbundled_program.a" clean_executorch_install_folders retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ diff --git a/examples/qualcomm/test_qualcomm.sh b/examples/qualcomm/test_qualcomm.sh index 19d3d798418..6f906f0dc74 100644 --- a/examples/qualcomm/test_qualcomm.sh +++ b/examples/qualcomm/test_qualcomm.sh @@ -12,7 +12,7 @@ set -e # shellcheck source=/dev/null source "$(dirname "${BASH_SOURCE[0]}")/../../../.ci/scripts/utils.sh" cmake_install_executorch_qnn_lib() { - echo "Installing libexecutorch.a, libqnn_executorch_backend.a" + echo "Installing libprim_ops_lib.a, libqnn_executorch_backend.a" rm -rf cmake-out retry cmake -DBUCK2="$BUCK" \ diff --git a/scripts/build_apple_frameworks.sh b/scripts/build_apple_frameworks.sh index 643308859e8..cc26970475c 100755 --- a/scripts/build_apple_frameworks.sh +++ b/scripts/build_apple_frameworks.sh @@ -26,12 +26,12 @@ PLATFORM_FLAGS=("OS64" "SIMULATORARM64" "MAC_ARM64") PLATFORM_TARGET=("17.0" "17.0" "10.15") FRAMEWORK_EXECUTORCH="executorch:\ -libexecutorch.a,\ libexecutorch_core.a,\ libextension_apple.a,\ libextension_data_loader.a,\ libextension_module.a,\ libextension_tensor.a,\ +libprim_ops_lib.a,\ :$HEADERS_PATH" FRAMEWORK_BACKEND_COREML="backend_coreml:\ diff --git a/test/build_optimized_size_test.sh b/test/build_optimized_size_test.sh index 181c2ce617d..50e2b9be282 100644 --- a/test/build_optimized_size_test.sh +++ b/test/build_optimized_size_test.sh @@ -18,7 +18,7 @@ set -e source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh" cmake_install_executorch_lib() { - echo "Installing libexecutorch.a" + echo "Installing libprim_ops_lib.a" clean_executorch_install_folders update_tokenizers_git_submodule CXXFLAGS="-g" retry cmake -DBUCK2="$BUCK2" \ diff --git a/test/build_size_test.sh b/test/build_size_test.sh index cae5a015280..cc00efaf9af 100644 --- a/test/build_size_test.sh +++ b/test/build_size_test.sh @@ -18,7 +18,7 @@ EXTRA_BUILD_ARGS="${@:-}" COMMON_CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0" cmake_install_executorch_lib() { - echo "Installing libexecutorch.a" + echo "Installing libprim_ops_lib.a" clean_executorch_install_folders update_tokenizers_git_submodule local EXTRA_BUILD_ARGS="${@}" From 3c82cb4652efffa7fa462edb1e894efaf77246d7 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 16:11:13 -0700 Subject: [PATCH 6/8] One more --- examples/apple/coreml/scripts/build_executor_runner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/apple/coreml/scripts/build_executor_runner.sh b/examples/apple/coreml/scripts/build_executor_runner.sh index bdfbf24a0cf..0168c39606b 100755 --- a/examples/apple/coreml/scripts/build_executor_runner.sh +++ b/examples/apple/coreml/scripts/build_executor_runner.sh @@ -83,7 +83,7 @@ cp -rf "$COREML_DIR_PATH/runtime/include/" "$INCLUDE_DIR_PATH" # Copy required libraries echo "ExecuTorch: Copying libraries" mkdir "$LIBRARIES_DIR_PATH" -find "$CMAKE_BUILD_DIR_PATH/" -name 'libexecutorch.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libexecutorch.a" \; +find "$CMAKE_BUILD_DIR_PATH/" -name 'libprim_ops_lib.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libprim_ops_lib.a" \; find "$CMAKE_BUILD_DIR_PATH/" -name 'libexecutorch_core.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libexecutorch_core.a" \; find "$CMAKE_BUILD_DIR_PATH/" -name 'libprotobuf-lite.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libprotobuf-lite.a" \; find "$CMAKE_BUILD_DIR_PATH/" -name 'libprotobuf-lited.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libprotobuf-lite.a" \; From 5459400193fc3e4925c5b19ed8b7a473caf7271a Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 16:22:51 -0700 Subject: [PATCH 7/8] Use separate prim_ops_lib rule --- CMakeLists.txt | 8 +------ kernels/prim_ops/CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 kernels/prim_ops/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 99c0aff8380..e13e076e40b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -610,13 +610,7 @@ endif() # # Provides primitive operators with registration. # -add_library(prim_ops_lib ${_executorch__srcs}) -target_link_libraries(prim_ops_lib PRIVATE executorch_core) -target_include_directories(prim_ops_lib PUBLIC ${_common_include_directories}) -target_compile_definitions(prim_ops_lib PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) -target_compile_options(prim_ops_lib PUBLIC ${_common_compile_options}) -target_link_options_shared_lib(prim_ops_lib) - +add_subdirectory(kernels/prim_ops) # # portable_ops_lib: A library to register core ATen ops using portable kernels, # see kernels/portable/CMakeLists.txt. diff --git a/kernels/prim_ops/CMakeLists.txt b/kernels/prim_ops/CMakeLists.txt new file mode 100644 index 00000000000..100141e2f8e --- /dev/null +++ b/kernels/prim_ops/CMakeLists.txt @@ -0,0 +1,37 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Kernel library for portable kernels. Please this file formatted by running: +# ~~~ +# cmake-format -i CMakeLists.txt +# ~~~ + +cmake_minimum_required(VERSION 3.19) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +# Source root directory for executorch. +if(NOT EXECUTORCH_ROOT) + set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) +endif() + +set(_common_compile_options -Wno-deprecated-declarations) + +add_library(prim_ops_lib ${_executorch__srcs}) +target_link_libraries(prim_ops_lib PRIVATE executorch_core) +target_include_directories(prim_ops_lib PUBLIC ${_common_include_directories}) +target_compile_definitions(prim_ops_lib PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) +target_compile_options(prim_ops_lib PUBLIC ${_common_compile_options}) +target_link_options_shared_lib(prim_ops_lib) + +install( + TARGETS prim_ops_lib + DESTINATION lib + PUBLIC_HEADER DESTINATION include/executorch/kernels/prim_ops/ +) From a7d6ca79e2721721c7158e2cce239681ceb4953c Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 7 May 2025 16:59:58 -0700 Subject: [PATCH 8/8] again --- kernels/prim_ops/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/kernels/prim_ops/CMakeLists.txt b/kernels/prim_ops/CMakeLists.txt index 100141e2f8e..ab9e9dcb1cc 100644 --- a/kernels/prim_ops/CMakeLists.txt +++ b/kernels/prim_ops/CMakeLists.txt @@ -21,6 +21,7 @@ if(NOT EXECUTORCH_ROOT) set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) endif() +list(TRANSFORM _executorch__srcs PREPEND "${EXECUTORCH_ROOT}/") set(_common_compile_options -Wno-deprecated-declarations) add_library(prim_ops_lib ${_executorch__srcs})