diff --git a/CMakePresets.json b/CMakePresets.json index 5006ba9ec05..ac19bbfed5f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,6 +15,7 @@ }, { "name": "macos-arm64", + "displayName": "Build everything buildable on macOS arm64", "inherits": ["common"], "generator": "Xcode", "cacheVariables": { @@ -28,6 +29,20 @@ "type": "equals", "rhs": "Darwin" } + }, + { + "name": "pybind", + "displayName": "Build pybindings exported in the wheel", + "inherits": ["common"], + "cacheVariables": { + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/pybind.cmake", + "CMAKE_OSX_DEPLOYMENT_TARGET": "10.15" + }, + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": ["Darwin", "Linux", "Windows"] + } } ] } diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 670f1fba6df..a1fee7427fc 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -25,24 +25,6 @@ endif() include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) -# NB: Enabling this will serialize execution of delegate instances Keeping this -# OFF by default to maintain existing behavior, to be revisited. -option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE - "Enable workspace sharing across different delegate instances" ON -) -# Keeping this OFF by default due to regressions in decode and model load with -# kleidi kernels -option(EXECUTORCH_XNNPACK_ENABLE_KLEIDI "Enable Arm Kleidi kernels" OFF) - -# Turning this on cache weights between partitions and methods. If weights -# are shared across methods/partitions then this can reduce load time and -# memory usage - -# Keeping this off maintains existing behavior. Turning this on serializes -# execution and initialization of delegates, to be revisited -option(EXECUTORCH_XNNPACK_ENABLE_WEIGHT_CACHE - "Enable weights cache to cache and manage all packed weights" OFF) - if(EXECUTORCH_XNNPACK_ENABLE_WEIGHT_CACHE) add_definitions(-DENABLE_XNNPACK_WEIGHTS_CACHE) endif() diff --git a/kernels/quantized/CMakeLists.txt b/kernels/quantized/CMakeLists.txt index bfcd8f7f324..e5d1a94e068 100644 --- a/kernels/quantized/CMakeLists.txt +++ b/kernels/quantized/CMakeLists.txt @@ -10,10 +10,6 @@ # ~~~ cmake_minimum_required(VERSION 3.19) -option(EXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT - "Build the optimized ops library for AOT export usage" OFF -) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) @@ -91,7 +87,13 @@ if(NOT CMAKE_GENERATOR STREQUAL "Xcode" # pybindings. if(TARGET portable_lib) add_library(quantized_pybind_kernels_lib ${_quantized_kernels__srcs}) - target_link_libraries(quantized_pybind_kernels_lib PRIVATE portable_lib) + target_link_libraries( + quantized_pybind_kernels_lib + PRIVATE + portable_lib + executorch_core + kernels_util_all_deps + ) target_compile_options( quantized_pybind_kernels_lib PUBLIC ${_common_compile_options} ) diff --git a/runtime/executor/test/CMakeLists.txt b/runtime/executor/test/CMakeLists.txt index 7a0e1be938d..c632ddffaba 100644 --- a/runtime/executor/test/CMakeLists.txt +++ b/runtime/executor/test/CMakeLists.txt @@ -148,6 +148,7 @@ et_cxx_test( portable_kernels extension_data_loader extension_runner_util + program_schema ) add_dependencies(tensor_parser_test generated_pte_files) set_property(TEST tensor_parser_test PROPERTY ENVIRONMENT ${test_env}) diff --git a/tools/cmake/preset/default.cmake b/tools/cmake/preset/default.cmake index 7b6830bd3c8..5dbaa1871ea 100644 --- a/tools/cmake/preset/default.cmake +++ b/tools/cmake/preset/default.cmake @@ -74,6 +74,11 @@ define_overridable_option( "Build the custom ops lib for AOT" BOOL OFF ) +define_overridable_option( + EXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT + "Build the optimized ops library for AOT export usage" + BOOL OFF +) define_overridable_option( EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "Build the Data Loader extension" @@ -109,6 +114,11 @@ define_overridable_option( "Build the training extension" BOOL OFF ) +define_overridable_option( + EXECUTORCH_BUILD_EXTENSION_APPLE + "Build the Apple extension" + BOOL OFF +) define_overridable_option( EXECUTORCH_BUILD_MPS "Build the MPS backend" @@ -227,6 +237,8 @@ define_overridable_option( set(_default_executorch_build_executor_runner ON) if(APPLE AND "${SDK_NAME}" STREQUAL "iphoneos") set(_default_executorch_build_executor_runner OFF) +elseif(DEFINED EXECUTORCH_BUILD_PRESET_FILE) + set(_default_executorch_build_executor_runner OFF) endif() define_overridable_option( EXECUTORCH_BUILD_EXECUTOR_RUNNER @@ -234,6 +246,32 @@ define_overridable_option( BOOL ${_default_executorch_build_executor_runner} ) +# NB: Enabling this will serialize execution of delegate instances Keeping this +# OFF by default to maintain existing behavior, to be revisited. +define_overridable_option( + EXECUTORCH_XNNPACK_SHARED_WORKSPACE + "Enable workspace sharing across different delegate instances" + BOOL ON +) +# Keeping this OFF by default due to regressions in decode and model load with +# kleidi kernels +define_overridable_option( + EXECUTORCH_XNNPACK_ENABLE_KLEIDI + "Enable Arm Kleidi kernels" + BOOL OFF +) +# Turning this on cache weights between partitions and methods. If weights +# are shared across methods/partitions then this can reduce load time and +# memory usage +# +# Keeping this off maintains existing behavior. Turning this on serializes +# execution and initialization of delegates, to be revisited +define_overridable_option( + EXECUTORCH_XNNPACK_ENABLE_WEIGHT_CACHE + "Enable weights cache to cache and manage all packed weights" + BOOL OFF +) + # MARK: - Validations # At this point all the options should be configured with their final value. diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake new file mode 100644 index 00000000000..4795ae60c2c --- /dev/null +++ b/tools/cmake/preset/pybind.cmake @@ -0,0 +1,30 @@ +# 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. + +set_overridable_option(EXECUTORCH_BUILD_PYBIND ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT ON) +# Enable logging even when in release mode. We are building for desktop, where +# saving a few kB is less important than showing useful error information to +# users. +set_overridable_option(EXECUTORCH_ENABLE_LOGGING ON) +set_overridable_option(EXECUTORCH_LOG_LEVEL Info) +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT ON) + + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_overridable_option(EXECUTORCH_BUILD_COREML ON) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Linux-specific code here +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32") + # Windows or other OS-specific code here +else() + message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for pybind: ${CMAKE_SYSTEM_NAME}") +endif()