diff --git a/.lintrunner.toml b/.lintrunner.toml index 07227998c2c..c060836cb72 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -136,6 +136,36 @@ init_command = [ '--requirement=requirements-lintrunner.txt', ] +[[linter]] +code = 'CMAKEFORMAT' +include_patterns = [ + "**/*.cmake", + "**/*.cmake.in", + "**/CMakeLists.txt", +] +exclude_patterns = [ + 'third-party/**', + '**/third-party/**', +] +command = [ + 'python', + '-m', + 'lintrunner_adapters', + 'run', + 'cmake_format_linter', + '--', + '@{{PATHSFILE}}', +] +init_command = [ + 'python', + '-m', + 'lintrunner_adapters', + 'run', + 'pip_init', + '--dry-run={{DRYRUN}}', + '--requirement=requirements-lintrunner.txt', +] + [[linter]] code = 'ETCAPITAL' include_patterns = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dc77596d37..f2fba8921f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,7 +284,9 @@ if(EXECUTORCH_BUILD_KERNELS_TORCHAO) set(TORCHAO_BUILD_CPU_AARCH64 ON) set(TORCHAO_ENABLE_ARM_NEON_DOT ON) - list(APPEND TORCHAO_INCLUDE_DIRS + list( + APPEND + TORCHAO_INCLUDE_DIRS ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include ${EXECUTORCH_ROOT}/third-party/ao @@ -292,7 +294,9 @@ if(EXECUTORCH_BUILD_KERNELS_TORCHAO) set(EXECUTORCH_INCLUDE_DIRS ${TORCHAO_INCLUDE_DIRS}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental) + add_subdirectory( + ${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental + ) executorch_target_link_options_shared_lib(torchao_ops_executorch) list(APPEND _executorch_kernels torchao_ops_executorch) endif() diff --git a/backends/arm/CMakeLists.txt b/backends/arm/CMakeLists.txt index 3830a1b1108..cdde13a85a4 100644 --- a/backends/arm/CMakeLists.txt +++ b/backends/arm/CMakeLists.txt @@ -19,69 +19,71 @@ set(_common_include_directories ) add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS) - # bare metal backend builds if(EXECUTORCH_BUILD_ARM_BAREMETAL) -add_compile_options("-Wall" "-Werror") + add_compile_options("-Wall" "-Werror") -# Third-party folder and Ethos-U driver inclued -set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party") -set(DRIVER_ETHOSU_INCLUDE_DIR "${THIRD_PARTY_ROOT}/ethos-u-core-driver/include") -include_directories(${DRIVER_ETHOSU_INCLUDE_DIR}) + # Third-party folder and Ethos-U driver inclued + set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party") + set(DRIVER_ETHOSU_INCLUDE_DIR + "${THIRD_PARTY_ROOT}/ethos-u-core-driver/include" + ) + include_directories(${DRIVER_ETHOSU_INCLUDE_DIR}) -set(_arm_baremetal_sources backends/arm/runtime/EthosUBackend.cpp - backends/arm/runtime/VelaBinStream.cpp -) -list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/") + set(_arm_baremetal_sources backends/arm/runtime/EthosUBackend.cpp + backends/arm/runtime/VelaBinStream.cpp + ) + list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/") -add_library(executorch_delegate_ethos_u STATIC ${_arm_baremetal_sources}) -target_link_libraries( - executorch_delegate_ethos_u PUBLIC executorch_core ethosu_core_driver -) + add_library(executorch_delegate_ethos_u STATIC ${_arm_baremetal_sources}) + target_link_libraries( + executorch_delegate_ethos_u PUBLIC executorch_core ethosu_core_driver + ) -install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets) + install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets) -# end config for bare metal builds + # end config for bare metal builds endif() - -# VGF backend builds +# VGF backend builds if(EXECUTORCH_BUILD_VGF) -# include libvgf -set(LIBVGF_PATH "${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/") - -set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party) -set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include) -set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk) - -set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a") -set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/") - -add_library(vgf STATIC IMPORTED) -set_property( TARGET vgf PROPERTY IMPORTED_LOCATION "${LIBVGF_STATIC}" ) -target_include_directories(vgf INTERFACE "${LIBVGF_INCLUDE}") - -# Add backend delegate for VGF -set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp - backends/arm/runtime/VGFSetup.cpp ) - -# vgf backend -list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/") -add_library(vgf_backend ${_vgf_backend_sources}) -target_include_directories( - vgf_backend PUBLIC - ${_common_include_directories} - ${VULKAN_HEADERS_PATH} - ${VOLK_HEADERS_PATH} -) -target_compile_options(vgf_backend PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK) - - -target_link_libraries(vgf_backend PRIVATE executorch_core) -target_link_libraries(vgf_backend PRIVATE vgf) -executorch_target_link_options_shared_lib(vgf_backend) - -# end config for VGF builds + # include libvgf + set(LIBVGF_PATH + "${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/" + ) + + set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party) + set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include) + set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk) + + set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a") + set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/") + + add_library(vgf STATIC IMPORTED) + set_property(TARGET vgf PROPERTY IMPORTED_LOCATION "${LIBVGF_STATIC}") + target_include_directories(vgf INTERFACE "${LIBVGF_INCLUDE}") + + # Add backend delegate for VGF + set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp + backends/arm/runtime/VGFSetup.cpp + ) + + # vgf backend + list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/") + add_library(vgf_backend ${_vgf_backend_sources}) + target_include_directories( + vgf_backend PUBLIC ${_common_include_directories} ${VULKAN_HEADERS_PATH} + ${VOLK_HEADERS_PATH} + ) + target_compile_options( + vgf_backend PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK + ) + + target_link_libraries(vgf_backend PRIVATE executorch_core) + target_link_libraries(vgf_backend PRIVATE vgf) + executorch_target_link_options_shared_lib(vgf_backend) + + # end config for VGF builds endif() diff --git a/backends/cadence/CMakeLists.txt b/backends/cadence/CMakeLists.txt index d541fafe957..47183bed21d 100644 --- a/backends/cadence/CMakeLists.txt +++ b/backends/cadence/CMakeLists.txt @@ -22,8 +22,9 @@ endif() include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. - ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS) @@ -38,52 +39,58 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER) executorch_target_link_options_shared_lib(executorch) executorch_target_link_options_shared_lib(portable_ops_lib) - target_include_directories(executorch INTERFACE ${_common_include_directories}) + target_include_directories( + executorch INTERFACE ${_common_include_directories} + ) find_package( - gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party + gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party ) - add_executable(cadence_runner - ${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp + add_executable( + cadence_runner + ${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp ) target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) target_include_directories( - etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include - ${EXECUTORCH_ROOT}/third-party/flatcc/include + etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include + ${EXECUTORCH_ROOT}/third-party/flatcc/include ) target_include_directories( - cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} - ${_common_include_directories} + cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} + ${_common_include_directories} ) target_link_libraries( - cadence_runner - executorch - gflags - etdump - extension_data_loader - bundled_program - cadence_ops_lib - flatccrt + cadence_runner + executorch + gflags + etdump + extension_data_loader + bundled_program + cadence_ops_lib + flatccrt ) endif() if(EXECUTORCH_NNLIB_OPT) set(TARGET_DIR hifi) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib - ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) + add_subdirectory( + ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib + ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 + ) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels) elseif(EXECUTORCH_FUSION_G3_OPT) set(TARGET_DIR fusion_g3) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib - ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) + add_subdirectory( + ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib + ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 + ) else() set(TARGET_DIR reference) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels) endif() - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/operators) diff --git a/backends/cadence/cadence.cmake b/backends/cadence/cadence.cmake index 0fa55c6a65b..a0e5ea86da1 100644 --- a/backends/cadence/cadence.cmake +++ b/backends/cadence/cadence.cmake @@ -43,7 +43,7 @@ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-clang++) set(CMAKE_C_FLAGS_INIT "-stdlib=libc++ -mtext-section-literals -mlongcalls") set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++ -mtext-section-literals -mlongcalls") -#workaround for larger compilation time +# workaround for larger compilation time set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -fno-strict-aliasing") set(CMAKE_SYSROOT ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}) diff --git a/backends/cadence/fusion_g3/operators/CMakeLists.txt b/backends/cadence/fusion_g3/operators/CMakeLists.txt index c29ffa91af9..a9501c687bb 100644 --- a/backends/cadence/fusion_g3/operators/CMakeLists.txt +++ b/backends/cadence/fusion_g3/operators/CMakeLists.txt @@ -69,16 +69,20 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch) target_link_libraries(aten_ops_cadence PRIVATE xa_nnlib) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. -${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) target_include_directories( - aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} - ${_common_include_directories} - ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/ - ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include/nnlib - ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include - ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/kernels/tables/include + aten_ops_cadence + PUBLIC + ${ROOT_DIR}/.. + ${CMAKE_BINARY_DIR} + ${_common_include_directories} + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/ + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include/nnlib + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/kernels/tables/include ) # Generate C++ bindings to register kernels into both PyTorch (for AOT) and @@ -93,6 +97,4 @@ generate_bindings_for_kernels( ) message("Generated files ${gen_command_sources}") -gen_operators_lib( - LIB_NAME "cadence_ops_lib" KERNEL_LIBS DEPS aten_ops_cadence -) +gen_operators_lib(LIB_NAME "cadence_ops_lib" KERNEL_LIBS DEPS aten_ops_cadence) diff --git a/backends/cadence/hifi/kernels/CMakeLists.txt b/backends/cadence/hifi/kernels/CMakeLists.txt index 972bb4b7ab1..936e28e2241 100644 --- a/backends/cadence/hifi/kernels/CMakeLists.txt +++ b/backends/cadence/hifi/kernels/CMakeLists.txt @@ -28,8 +28,9 @@ add_library( ${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_transpose_32.c ) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. -${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) target_include_directories( cadence_kernels @@ -39,7 +40,7 @@ target_include_directories( ${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include/nnlib ${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include ${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/ndsp/hifi4/include/ - ${_common_include_directories} + ${_common_include_directories} ) target_link_libraries(cadence_kernels PRIVATE xa_nnlib) diff --git a/backends/cadence/hifi/operators/CMakeLists.txt b/backends/cadence/hifi/operators/CMakeLists.txt index 806e2e41ff5..a3df52516c5 100644 --- a/backends/cadence/hifi/operators/CMakeLists.txt +++ b/backends/cadence/hifi/operators/CMakeLists.txt @@ -72,14 +72,15 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/select_copy_util.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/slice_util.cpp" "${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 PRIVATE cadence_kernels) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. -${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) target_include_directories( aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} @@ -88,9 +89,15 @@ target_include_directories( # Custom ops that are needed to run the test model. add_library( - custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp" "op_quantized_matmul_out.cpp" - "op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp" - "op_quantized_conv_out.cpp" "op_quantized_fully_connected_out" + custom_ops + "op_quantized_linear_out.cpp" + "op_quantized_layer_norm.cpp" + "op_quantized_matmul_out.cpp" + "op_quantize_per_tensor.cpp" + "op_quantized_relu_out.cpp" + "op_dequantize_per_tensor.cpp" + "op_quantized_conv_out.cpp" + "op_quantized_fully_connected_out" ) target_include_directories( custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} diff --git a/backends/cadence/reference/kernels/CMakeLists.txt b/backends/cadence/reference/kernels/CMakeLists.txt index 3fe0fe2101f..5af049418ce 100644 --- a/backends/cadence/reference/kernels/CMakeLists.txt +++ b/backends/cadence/reference/kernels/CMakeLists.txt @@ -8,9 +8,10 @@ add_library(cadence_kernels kernels.cpp) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. -${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) -target_include_directories(cadence_kernels PUBLIC . - ${_common_include_directories} +target_include_directories( + cadence_kernels PUBLIC . ${_common_include_directories} ) diff --git a/backends/cadence/reference/operators/CMakeLists.txt b/backends/cadence/reference/operators/CMakeLists.txt index 6a71af012e4..57a751fa303 100644 --- a/backends/cadence/reference/operators/CMakeLists.txt +++ b/backends/cadence/reference/operators/CMakeLists.txt @@ -67,8 +67,9 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch) target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. -${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 +) target_include_directories( aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} diff --git a/backends/mediatek/CMakeLists.txt b/backends/mediatek/CMakeLists.txt index 23e50e8cd8a..ed9b37e1998 100644 --- a/backends/mediatek/CMakeLists.txt +++ b/backends/mediatek/CMakeLists.txt @@ -30,12 +30,13 @@ target_link_libraries( ) target_sources( neuron_backend - INTERFACE $ - $ - $ - $ - $ - $ + INTERFACE + $ + $ + $ + $ + $ + $ PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronBackend.cpp ${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronExecutor.cpp ${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronBufferAllocator.cpp diff --git a/backends/nxp/CMakeLists.txt b/backends/nxp/CMakeLists.txt index 0a9d72d3555..54839e38af4 100644 --- a/backends/nxp/CMakeLists.txt +++ b/backends/nxp/CMakeLists.txt @@ -3,14 +3,13 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -set( - _common_include_directories - ${CMAKE_CURRENT_SOURCE_DIR}/../../.. - ${CMAKE_CURRENT_SOURCE_DIR}/../../runtime/core/portable_type/c10 +set(_common_include_directories + ${CMAKE_CURRENT_SOURCE_DIR}/../../.. + ${CMAKE_CURRENT_SOURCE_DIR}/../../runtime/core/portable_type/c10 ) add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS) -set(_neutron_sources ${CMAKE_CURRENT_SOURCE_DIR}/runtime/NeutronBackend.cpp ) +set(_neutron_sources ${CMAKE_CURRENT_SOURCE_DIR}/runtime/NeutronBackend.cpp) add_library(executorch_delegate_neutron STATIC ${_neutron_sources}) target_include_directories( diff --git a/backends/openvino/CMakeLists.txt b/backends/openvino/CMakeLists.txt index bf5fc3b217e..cb240805665 100644 --- a/backends/openvino/CMakeLists.txt +++ b/backends/openvino/CMakeLists.txt @@ -41,35 +41,41 @@ target_compile_options(openvino_backend PRIVATE -frtti -fexceptions) target_include_directories(openvino_backend PUBLIC ${COMMON_INCLUDE_DIRS}) # Link OpenVINO and ExecuteTorch core libraries -target_link_libraries(openvino_backend PRIVATE openvino::runtime executorch_core) +target_link_libraries( + openvino_backend PRIVATE openvino::runtime executorch_core +) # Add source files for OpenVINO backend -target_sources(openvino_backend PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/OpenvinoBackend.cpp) +target_sources( + openvino_backend + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/OpenvinoBackend.cpp +) executorch_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) - - set(_openvino_executor_runner__srcs - ${EXECUTORCH_ROOT}/examples/portable/executor_runner/executor_runner.cpp - ${EXECUTORCH_ROOT}/extension/data_loader/file_data_loader.cpp - ${EXECUTORCH_ROOT}/extension/evalue_util/print_evalue.cpp - ${EXECUTORCH_ROOT}/extension/runner_util/inputs.cpp - ${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} - ) - target_compile_options(openvino_executor_runner PUBLIC ${_common_compile_options}) + # Build executor runner binary for openvino backend + list(APPEND openvino_executor_runner_libs openvino_backend executorch) + + set(_openvino_executor_runner__srcs + ${EXECUTORCH_ROOT}/examples/portable/executor_runner/executor_runner.cpp + ${EXECUTORCH_ROOT}/extension/data_loader/file_data_loader.cpp + ${EXECUTORCH_ROOT}/extension/evalue_util/print_evalue.cpp + ${EXECUTORCH_ROOT}/extension/runner_util/inputs.cpp + ${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} + ) + target_compile_options( + openvino_executor_runner PUBLIC ${_common_compile_options} + ) endif() - - # Install OpenVINO backend library to the lib directory install(TARGETS openvino_backend DESTINATION lib) diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index f2e40f92caf..babcf4cfc7c 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -198,8 +198,9 @@ target_link_libraries( qnn_dlc_manager ) target_link_libraries( - qnn_executorch_backend PRIVATE qnn_executorch_header qnn_schema qnn_manager - executorch_core extension_tensor qnn_backend_options + qnn_executorch_backend + PRIVATE qnn_executorch_header qnn_schema qnn_manager executorch_core + extension_tensor qnn_backend_options ) set_target_properties( qnn_executorch_backend PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" diff --git a/backends/qualcomm/runtime/backends/CMakeLists.txt b/backends/qualcomm/runtime/backends/CMakeLists.txt index 2497aa48340..6a44f3234c5 100644 --- a/backends/qualcomm/runtime/backends/CMakeLists.txt +++ b/backends/qualcomm/runtime/backends/CMakeLists.txt @@ -68,11 +68,12 @@ target_sources( PUBLIC ${CMAKE_CURRENT_LIST_DIR}/QnnContextCommon.h ${CMAKE_CURRENT_LIST_DIR}/htpbackend/HtpContext.h ${CMAKE_CURRENT_LIST_DIR}/irbackend/IrContext.h - PRIVATE ${CMAKE_CURRENT_LIST_DIR}/QnnContextCommon.cpp - ${CMAKE_CURRENT_LIST_DIR}/htpbackend/HtpContext.cpp - ${CMAKE_CURRENT_LIST_DIR}/htpbackend/HtpContextCustomConfig.h - ${HOST_ARCHITECTURE}/HtpContextCustomConfig.cpp - ${CMAKE_CURRENT_LIST_DIR}/irbackend/${CMAKE_SYSTEM_PROCESSOR}/IrContext.cpp + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/QnnContextCommon.cpp + ${CMAKE_CURRENT_LIST_DIR}/htpbackend/HtpContext.cpp + ${CMAKE_CURRENT_LIST_DIR}/htpbackend/HtpContextCustomConfig.h + ${HOST_ARCHITECTURE}/HtpContextCustomConfig.cpp + ${CMAKE_CURRENT_LIST_DIR}/irbackend/${CMAKE_SYSTEM_PROCESSOR}/IrContext.cpp ) # qnn_backend_cache @@ -137,5 +138,6 @@ target_sources( target_sources( qnn_dlc_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR}/QnnDlcManager.h - PRIVATE ${CMAKE_CURRENT_LIST_DIR}/irbackend/${CMAKE_SYSTEM_PROCESSOR}/QnnDlcManager.cpp + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/irbackend/${CMAKE_SYSTEM_PROCESSOR}/QnnDlcManager.cpp ) diff --git a/backends/vulkan/test/CMakeLists.txt b/backends/vulkan/test/CMakeLists.txt index da25b6e88d1..e3bce1d8baf 100644 --- a/backends/vulkan/test/CMakeLists.txt +++ b/backends/vulkan/test/CMakeLists.txt @@ -35,10 +35,11 @@ if(TARGET vulkan_backend) set(PYTHON_EXECUTABLE python3) endif() - # Include this file to access executorch_target_link_options_shared_lib This is required - # to provide access to executorch_target_link_options_shared_lib which allows libraries - # to be linked with the --whole-archive flag. This is required for libraries - # that perform dynamic registration via static initialization. + # Include this file to access executorch_target_link_options_shared_lib This + # is required to provide access to executorch_target_link_options_shared_lib + # which allows libraries to be linked with the --whole-archive flag. This is + # required for libraries that perform dynamic registration via static + # initialization. include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) include(../cmake/ShaderLibrary.cmake) @@ -82,8 +83,8 @@ 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_core - test_shaderlib + 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 c19e818f63d..071c5bd0a40 100644 --- a/backends/vulkan/test/op_tests/CMakeLists.txt +++ b/backends/vulkan/test/op_tests/CMakeLists.txt @@ -29,10 +29,10 @@ if(NOT EXECUTORCH_ROOT) set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) endif() -# Include this file to access executorch_target_link_options_shared_lib This is required to -# provide access to executorch_target_link_options_shared_lib which allows libraries to be -# linked with the --whole-archive flag. This is required for libraries that -# perform dynamic registration via static initialization. +# Include this file to access executorch_target_link_options_shared_lib This is +# required to provide access to executorch_target_link_options_shared_lib which +# allows libraries to be linked with the --whole-archive flag. This is required +# for libraries that perform dynamic registration via static initialization. include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) get_torch_base_path(TORCH_BASE_PATH) diff --git a/backends/xnnpack/cmake/Dependencies.cmake b/backends/xnnpack/cmake/Dependencies.cmake index 60ab7db6c05..8d5d0845430 100644 --- a/backends/xnnpack/cmake/Dependencies.cmake +++ b/backends/xnnpack/cmake/Dependencies.cmake @@ -35,25 +35,26 @@ set(XNNPACK_BUILD_TESTS set(XNNPACK_ENABLE_AVXVNNI OFF CACHE BOOL "" - ) -# Work around observed failure: https://github.com/pytorch/executorch/pull/10362#issuecomment-2906391232 +) +# Work around observed failure: +# https://github.com/pytorch/executorch/pull/10362#issuecomment-2906391232 set(XNNPACK_ENABLE_AVX512VNNIGFNI - OFF - CACHE BOOL "") + OFF + CACHE BOOL "" +) if(EXECUTORCH_XNNPACK_ENABLE_KLEIDI) - set(XNNPACK_ENABLE_KLEIDIAI - ON - CACHE BOOL "" - ) + set(XNNPACK_ENABLE_KLEIDIAI + ON + CACHE BOOL "" + ) else() - set(XNNPACK_ENABLE_KLEIDIAI - OFF - CACHE BOOL "" - ) + set(XNNPACK_ENABLE_KLEIDIAI + OFF + CACHE BOOL "" + ) endif() - set(XNNPACK_BUILD_ALL_MICROKERNELS OFF CACHE BOOL "" diff --git a/backends/xnnpack/test/CMakeLists.txt b/backends/xnnpack/test/CMakeLists.txt index 12d0a6d45be..395fb01d189 100644 --- a/backends/xnnpack/test/CMakeLists.txt +++ b/backends/xnnpack/test/CMakeLists.txt @@ -17,9 +17,8 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake) -set(_test_srcs - runtime/test_xnnexecutor.cpp - ${EXECUTORCH_ROOT}/extension/threadpool/test/threadpool_test.cpp +set(_test_srcs runtime/test_xnnexecutor.cpp + ${EXECUTORCH_ROOT}/extension/threadpool/test/threadpool_test.cpp ) et_cxx_test( diff --git a/codegen/tools/CMakeLists.txt b/codegen/tools/CMakeLists.txt index 6690418dd6f..489a96aafb6 100644 --- a/codegen/tools/CMakeLists.txt +++ b/codegen/tools/CMakeLists.txt @@ -19,27 +19,16 @@ target_compile_definitions( # Include directories target_include_directories( - selective_build PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../.. + selective_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../.. ) # Compile options target_compile_options( - selective_build PUBLIC - -Wno-deprecated-declarations - -fPIC - -frtti - -fexceptions + selective_build PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions ) # Link against required libraries -target_link_libraries( - selective_build PRIVATE - executorch_core - program_schema -) +target_link_libraries(selective_build PRIVATE executorch_core program_schema) # Install the module -install(TARGETS selective_build - LIBRARY DESTINATION executorch/codegen/tools -) +install(TARGETS selective_build LIBRARY DESTINATION executorch/codegen/tools) diff --git a/devtools/CMakeLists.txt b/devtools/CMakeLists.txt index 85492075b8c..a267232fe6d 100644 --- a/devtools/CMakeLists.txt +++ b/devtools/CMakeLists.txt @@ -5,7 +5,9 @@ # LICENSE file in the root directory of this source tree. # The include directory that will contain the generated schema headers. -set(DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE ${CMAKE_BINARY_DIR}/devtools/include) +set(DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE + ${CMAKE_BINARY_DIR}/devtools/include +) set(DEVTOOLS_INCLUDE_DIR $ ) diff --git a/devtools/etdump/CMakeLists.txt b/devtools/etdump/CMakeLists.txt index 040b100f940..ca4df1d2a82 100644 --- a/devtools/etdump/CMakeLists.txt +++ b/devtools/etdump/CMakeLists.txt @@ -4,24 +4,28 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -set( - _schema_files - etdump_schema_flatcc.fbs - scalar_type.fbs -) +set(_schema_files etdump_schema_flatcc.fbs scalar_type.fbs) set(_schema_outputs) foreach(schema_file ${_schema_files}) list(APPEND _etdump_schema__srcs "${CMAKE_CURRENT_SOURCE_DIR}/${schema_file}") string(REGEX REPLACE "[.]fbs$" "_reader.h" generated_reader "${schema_file}") - list(APPEND _schema_outputs "${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/etdump/${generated_reader}") + list(APPEND _schema_outputs + "${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/etdump/${generated_reader}" + ) - string(REGEX REPLACE "[.]fbs$" "_builder.h" generated_builder "${schema_file}") - list(APPEND _schema_outputs "${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/etdump/${generated_builder}") + string(REGEX REPLACE "[.]fbs$" "_builder.h" generated_builder + "${schema_file}" + ) + list(APPEND _schema_outputs + "${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/etdump/${generated_builder}" + ) endforeach() -file(MAKE_DIRECTORY ${DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE}/executorch/devtools/etdump) +file(MAKE_DIRECTORY + ${DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE}/executorch/devtools/etdump +) add_custom_command( OUTPUT ${_schema_outputs} COMMAND @@ -47,16 +51,13 @@ add_library( ) target_link_libraries( etdump - PUBLIC - flatccrt - PRIVATE - executorch + PUBLIC flatccrt + PRIVATE executorch ) target_include_directories( etdump - PUBLIC - ${DEVTOOLS_INCLUDE_DIR} - $ + PUBLIC ${DEVTOOLS_INCLUDE_DIR} + $ ) install( diff --git a/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake b/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake index 68fbf8985e9..45e786e4acf 100644 --- a/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake +++ b/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake @@ -97,7 +97,5 @@ add_compile_options( # -Wall -Wextra -Wcast-align -Wdouble-promotion -Wformat # -Wmissing-field-initializers -Wnull-dereference -Wredundant-decls -Wshadow # -Wswitch -Wswitch-default -Wunused -Wno-redundant-decls - -Wno-error=deprecated-declarations - -Wno-error=shift-count-overflow - -Wno-psabi + -Wno-error=deprecated-declarations -Wno-error=shift-count-overflow -Wno-psabi ) diff --git a/examples/devtools/CMakeLists.txt b/examples/devtools/CMakeLists.txt index e9aa683f1fe..38a98e83dd7 100644 --- a/examples/devtools/CMakeLists.txt +++ b/examples/devtools/CMakeLists.txt @@ -81,12 +81,10 @@ if(EXECUTORCH_BUILD_COREML) NO_DEFAULT_PATH ) - target_link_libraries( - example_runner "-Wl,-force_load" coremldelegate - ) + target_link_libraries(example_runner "-Wl,-force_load" coremldelegate) target_link_libraries( - example_runner ${PROTOBUF_LITE} ${ACCELERATE_FRAMEWORK} - ${COREML_FRAMEWORK} ${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY} + example_runner ${PROTOBUF_LITE} ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK} + ${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY} ) endif() diff --git a/examples/mediatek/CMakeLists.txt b/examples/mediatek/CMakeLists.txt index 2e79130e5c6..57c4b13e5cb 100644 --- a/examples/mediatek/CMakeLists.txt +++ b/examples/mediatek/CMakeLists.txt @@ -29,10 +29,11 @@ endif() set(_common_compile_options -Wno-deprecated-declarations -fPIC) # Let files say "include ". -set(_common_include_directories ${EXECUTORCH_ROOT}/.. - ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 - ${EXECUTORCH_ROOT}/extension/llm/tokenizers/include - ${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/json/single_include) +set(_common_include_directories + ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10 + ${EXECUTORCH_ROOT}/extension/llm/tokenizers/include + ${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/json/single_include +) # # The `__srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}. @@ -73,7 +74,10 @@ if(${ANDROID}) ) target_link_libraries( - mtk_executor_runner ${_executor_runner_libs} executorch neuron_backend + mtk_executor_runner + ${_executor_runner_libs} + executorch + neuron_backend executorch_core extension_evalue_util extension_runner_util @@ -83,42 +87,30 @@ if(${ANDROID}) add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS) set(_mtk_oss_executor_runner__srcs ${_executor_runner__srcs}) - list( - TRANSFORM - _mtk_oss_executor_runner__srcs - PREPEND - "${EXECUTORCH_SOURCE_DIR}/" + list(TRANSFORM _mtk_oss_executor_runner__srcs + PREPEND "${EXECUTORCH_SOURCE_DIR}/" ) - list( - FILTER - _mtk_oss_executor_runner__srcs - EXCLUDE REGEX - ".*executor_runner.cpp$" + list(FILTER _mtk_oss_executor_runner__srcs EXCLUDE REGEX + ".*executor_runner.cpp$" ) - list( - PREPEND - _mtk_oss_executor_runner__srcs - ${CMAKE_CURRENT_LIST_DIR}/executor_runner/mtk_oss_executor_runner.cpp + list(PREPEND _mtk_oss_executor_runner__srcs + ${CMAKE_CURRENT_LIST_DIR}/executor_runner/mtk_oss_executor_runner.cpp ) add_executable(mtk_oss_executor_runner ${_mtk_oss_executor_runner__srcs}) - target_include_directories(mtk_oss_executor_runner - PUBLIC - ${_common_include_directories} - ${EXECUTORCH_ROOT}/cmake-android-out/third-party/gflags/include + target_include_directories( + mtk_oss_executor_runner + PUBLIC ${_common_include_directories} + ${EXECUTORCH_ROOT}/cmake-android-out/third-party/gflags/include ) - target_link_libraries(mtk_oss_executor_runner - ${_executor_runner_libs} - extension_module - executorch - neuron_backend - gflags + target_link_libraries( + mtk_oss_executor_runner ${_executor_runner_libs} extension_module + executorch neuron_backend gflags ) - target_compile_options(mtk_oss_executor_runner - PUBLIC - ${_common_compile_options} + target_compile_options( + mtk_oss_executor_runner PUBLIC ${_common_compile_options} ) set(_mtk_llama_executor_runner__srcs ${_mtk_executor_runner__srcs}) @@ -130,17 +122,21 @@ if(${ANDROID}) ) # Build ABSL and RE2 set(EXTENSIONS_LLM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../extension/llm) - set(THIRD_PARTY_ABSL_DIR ${EXTENSIONS_LLM_DIR}/tokenizers/third-party/abseil-cpp) + set(THIRD_PARTY_ABSL_DIR + ${EXTENSIONS_LLM_DIR}/tokenizers/third-party/abseil-cpp + ) set(THIRD_PARTY_RE2_DIR ${EXTENSIONS_LLM_DIR}/tokenizers/third-party/re2) set(ABSL_ENABLE_INSTALL ON) set(ABSL_PROPAGATE_CXX_STD ON) set(_pic_flag ${CMAKE_POSITION_INDEPENDENT_CODE}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_subdirectory( - ${THIRD_PARTY_ABSL_DIR} ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/abseil + ${THIRD_PARTY_ABSL_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/abseil ) add_subdirectory( - ${THIRD_PARTY_RE2_DIR} ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/re2 + ${THIRD_PARTY_RE2_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/re2 ) set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag}) @@ -148,10 +144,13 @@ if(${ANDROID}) set(LLAMA2_TOKENIZER_DIR ${EXTENSIONS_LLM_DIR}/tokenizers) add_library(tokenizer STATIC) target_include_directories( - tokenizer PUBLIC ${_common_include_directories} ${THIRD_PARTY_ABSL_DIR} - ${THIRD_PARTY_RE2_DIR} ${LLAMA2_TOKENIZER_DIR}/include - ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/pcre2 - ${EXECUTORCH_ROOT}/extension/llm/tokenizers/include + tokenizer + PUBLIC ${_common_include_directories} + ${THIRD_PARTY_ABSL_DIR} + ${THIRD_PARTY_RE2_DIR} + ${LLAMA2_TOKENIZER_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/pcre2 + ${EXECUTORCH_ROOT}/extension/llm/tokenizers/include ) target_link_libraries(tokenizer PRIVATE re2::re2) target_sources( @@ -178,12 +177,8 @@ if(${ANDROID}) add_executable(mtk_llama_executor_runner ${_mtk_llama_executor_runner__srcs}) target_link_libraries( - mtk_llama_executor_runner - ${_executor_runner_libs} - neuron_backend - gflags - mtk_llama_executor_lib - tokenizer + mtk_llama_executor_runner ${_executor_runner_libs} neuron_backend gflags + mtk_llama_executor_lib tokenizer ) target_compile_options( mtk_llama_executor_runner PUBLIC ${_common_compile_options} diff --git a/examples/models/llama/CMakeLists.txt b/examples/models/llama/CMakeLists.txt index efa9c8e4009..add9adc2cc0 100644 --- a/examples/models/llama/CMakeLists.txt +++ b/examples/models/llama/CMakeLists.txt @@ -15,7 +15,7 @@ # ~~~ # It should also be cmake-lint clean. # -cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE +cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE project(llama_runner) # Duplicating options as root CMakeLists.txt @@ -117,7 +117,9 @@ endif() if(EXECUTORCH_BUILD_TORCHAO) # Currently only enable this on Arm-based Macs - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL + "arm64" + ) set(TORCHAO_BUILD_ATEN_OPS OFF) set(TORCHAO_BUILD_EXECUTORCH_OPS ON) set(TORCHAO_BUILD_CPU_AARCH64 ON) @@ -131,7 +133,8 @@ if(EXECUTORCH_BUILD_TORCHAO) if(EXECUTORCH_BUILD_MPS) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../third-party/ao/torchao/experimental/ops/mps - ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/ao/torchao/experimental/ops/mps) + ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/ao/torchao/experimental/ops/mps + ) executorch_target_link_options_shared_lib(torchao_ops_mps_executorch) list(APPEND link_libraries torchao_ops_mps_executorch) endif() @@ -218,9 +221,6 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") endif() endif() -target_include_directories( - llama_main - PUBLIC ${_common_include_directories} -) +target_include_directories(llama_main PUBLIC ${_common_include_directories}) target_link_libraries(llama_main PUBLIC llama_runner ${link_libraries}) target_compile_options(llama_main PUBLIC ${_common_compile_options}) diff --git a/examples/models/llama/runner/CMakeLists.txt b/examples/models/llama/runner/CMakeLists.txt index ebe1fb201f2..7c6c5413ab3 100644 --- a/examples/models/llama/runner/CMakeLists.txt +++ b/examples/models/llama/runner/CMakeLists.txt @@ -23,13 +23,10 @@ endif() include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake) -# The buck-based executorch_srcs.cmake setup was crossing package -# boundaries and trying to build stuff from -# executorch/extension/llm/runner and tokenizers. Just set up sources -# manually. -set(llama_runner_srcs - runner.cpp - ../tokenizer/llama_tiktoken.cpp) +# The buck-based executorch_srcs.cmake setup was crossing package boundaries and +# trying to build stuff from executorch/extension/llm/runner and tokenizers. +# Just set up sources manually. +set(llama_runner_srcs runner.cpp ../tokenizer/llama_tiktoken.cpp) if(CMAKE_TOOLCHAIN_IOS OR ANDROID @@ -59,6 +56,6 @@ target_link_libraries(llama_runner PUBLIC tokenizers::tokenizers) target_include_directories( llama_runner PUBLIC ${EXECUTORCH_ROOT}/extension/llm/tokenizers/include - ${EXECUTORCH_ROOT}/.. + ${EXECUTORCH_ROOT}/.. ) target_compile_options(llama_runner PUBLIC ${_preprocessor_flag}) diff --git a/examples/models/llava/CMakeLists.txt b/examples/models/llava/CMakeLists.txt index 500265cbb77..cf9d54ad3ec 100644 --- a/examples/models/llava/CMakeLists.txt +++ b/examples/models/llava/CMakeLists.txt @@ -21,7 +21,6 @@ project(llava) # Duplicating options as root CMakeLists.txt option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "Build the optimized kernels" OFF) - include(CMakeDependentOption) # # pthreadpool: build pthreadpool library. Disable on unsupported platforms diff --git a/examples/models/llava/runner/CMakeLists.txt b/examples/models/llava/runner/CMakeLists.txt index ce7c0968d9e..88ad8590ee5 100644 --- a/examples/models/llava/runner/CMakeLists.txt +++ b/examples/models/llava/runner/CMakeLists.txt @@ -26,9 +26,7 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake) set(_common_include_directories ${EXECUTORCH_ROOT}/..) # build llava_runner library -set(_llava_runner__srcs - "${CMAKE_CURRENT_SOURCE_DIR}/llava_runner.cpp" -) +set(_llava_runner__srcs "${CMAKE_CURRENT_SOURCE_DIR}/llava_runner.cpp") if(NOT TARGET extension_llm_runner) message( @@ -40,8 +38,9 @@ endif() add_library(llava_runner STATIC ${_llava_runner__srcs}) target_include_directories(llava_runner PRIVATE ${_common_include_directories}) -set(llava_runner_deps executorch_core extension_data_loader extension_llm_runner - extension_module extension_tensor extension_flat_tensor +set(llava_runner_deps + executorch_core extension_data_loader extension_llm_runner extension_module + extension_tensor extension_flat_tensor ) target_link_libraries(llava_runner PUBLIC ${llava_runner_deps}) diff --git a/examples/models/phi-3-mini/CMakeLists.txt b/examples/models/phi-3-mini/CMakeLists.txt index 4e55d4f9cb0..3c7ed6a4acb 100644 --- a/examples/models/phi-3-mini/CMakeLists.txt +++ b/examples/models/phi-3-mini/CMakeLists.txt @@ -31,7 +31,7 @@ set(BUILD_TESTING OFF) if(NOT TARGET extension_llm_runner) message( FATAL_ERROR - "ExecuTorch must be installed with EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER enabled." + "ExecuTorch must be installed with EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER enabled." ) endif() diff --git a/examples/models/yolo12/CMakeLists.txt b/examples/models/yolo12/CMakeLists.txt index 9c92e5eaeae..60b11685bdf 100644 --- a/examples/models/yolo12/CMakeLists.txt +++ b/examples/models/yolo12/CMakeLists.txt @@ -37,7 +37,6 @@ set(link_libraries gflags) list(APPEND link_libraries portable_ops_lib portable_kernels) executorch_target_link_options_shared_lib(portable_ops_lib) - if(USE_XNNPACK_BACKEND) set(xnnpack_backend_libs xnnpack_backend XNNPACK microkernels-prod) list(APPEND link_libraries ${xnnpack_backend_libs}) @@ -49,9 +48,10 @@ if(USE_OPENVINO_BACKEND) target_include_directories( openvino_backend - INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../include - ${CMAKE_CURRENT_BINARY_DIR}/../../include/executorch/runtime/core/portable_type/c10 - ${CMAKE_CURRENT_BINARY_DIR}/../../lib + INTERFACE + ${CMAKE_CURRENT_BINARY_DIR}/../../include + ${CMAKE_CURRENT_BINARY_DIR}/../../include/executorch/runtime/core/portable_type/c10 + ${CMAKE_CURRENT_BINARY_DIR}/../../lib ) list(APPEND link_libraries openvino_backend) executorch_target_link_options_shared_lib(openvino_backend) @@ -72,14 +72,13 @@ set(PROJECT_SOURCES ) add_executable(Yolo12DetectionDemo ${PROJECT_SOURCES}) -target_link_libraries(Yolo12DetectionDemo PUBLIC - ${link_libraries} - ${OpenCV_LIBS} - executorch_core - extension_module - extension_tensor +target_link_libraries( + Yolo12DetectionDemo PUBLIC ${link_libraries} ${OpenCV_LIBS} executorch_core + extension_module extension_tensor ) find_package(Threads REQUIRED) target_link_libraries(Yolo12DetectionDemo PRIVATE Threads::Threads) -target_include_directories(Yolo12DetectionDemo PUBLIC ${_common_include_directories}) \ No newline at end of file +target_include_directories( + Yolo12DetectionDemo PUBLIC ${_common_include_directories} +) diff --git a/examples/qualcomm/oss_scripts/moshi/CMakeLists.txt b/examples/qualcomm/oss_scripts/moshi/CMakeLists.txt index 70356e54906..0853866c50b 100644 --- a/examples/qualcomm/oss_scripts/moshi/CMakeLists.txt +++ b/examples/qualcomm/oss_scripts/moshi/CMakeLists.txt @@ -7,28 +7,26 @@ set(_qnn_mimi_decoder_runner__srcs ${CMAKE_CURRENT_LIST_DIR}/qnn_mimi_decoder_runner.cpp ${CMAKE_CURRENT_LIST_DIR}/runner/runner.cpp - ${CMAKE_CURRENT_LIST_DIR}/runner/runner.h + ${CMAKE_CURRENT_LIST_DIR}/runner/runner.h ) # build mimi decoder runner add_executable(qnn_mimi_decoder_runner ${_qnn_mimi_decoder_runner__srcs}) target_include_directories( - qnn_mimi_decoder_runner PUBLIC ${_common_include_directories} + qnn_mimi_decoder_runner PUBLIC ${_common_include_directories} ) target_link_libraries( - qnn_mimi_decoder_runner - qnn_executorch_backend - executorch_core - extension_module - extension_data_loader - extension_flat_tensor - gflags + qnn_mimi_decoder_runner + qnn_executorch_backend + executorch_core + extension_module + extension_data_loader + extension_flat_tensor + gflags ) -target_compile_options( - qnn_llama_runner PUBLIC ${_common_compile_options} -) +target_compile_options(qnn_llama_runner PUBLIC ${_common_compile_options}) set_target_properties( - qnn_mimi_decoder_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" + qnn_mimi_decoder_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" ) diff --git a/examples/qualcomm/oss_scripts/t5/CMakeLists.txt b/examples/qualcomm/oss_scripts/t5/CMakeLists.txt index 70fb613bb22..1bbec379341 100644 --- a/examples/qualcomm/oss_scripts/t5/CMakeLists.txt +++ b/examples/qualcomm/oss_scripts/t5/CMakeLists.txt @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. - # preprocess qnn runner src files for t5 set(_qnn_t5_runner__srcs ${CMAKE_CURRENT_LIST_DIR}/qnn_t5_runner.cpp @@ -19,10 +18,7 @@ set(_qnn_t5_runner__srcs # build qnn t5 runner add_executable(qnn_t5_runner ${_qnn_t5_runner__srcs}) -target_include_directories( - qnn_t5_runner PUBLIC ${_common_include_directories} -) - +target_include_directories(qnn_t5_runner PUBLIC ${_common_include_directories}) target_link_libraries( qnn_t5_runner @@ -37,9 +33,7 @@ target_link_libraries( tokenizers::tokenizers ) -target_compile_options( - qnn_t5_runner PUBLIC ${_common_compile_options} -) +target_compile_options(qnn_t5_runner PUBLIC ${_common_compile_options}) set_target_properties( - qnn_t5_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" + qnn_t5_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" ) diff --git a/examples/qualcomm/oss_scripts/whisper/CMakeLists.txt b/examples/qualcomm/oss_scripts/whisper/CMakeLists.txt index 5845575cba2..8f7d0f9a9be 100644 --- a/examples/qualcomm/oss_scripts/whisper/CMakeLists.txt +++ b/examples/qualcomm/oss_scripts/whisper/CMakeLists.txt @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. - # preprocess qnn runner src files for whisper set(_qnn_whisper_runner__srcs ${CMAKE_CURRENT_LIST_DIR}/qnn_whisper_runner.cpp @@ -20,10 +19,9 @@ set(_qnn_whisper_runner__srcs # build qnn whisper runner add_executable(qnn_whisper_runner ${_qnn_whisper_runner__srcs}) target_include_directories( - qnn_whisper_runner PUBLIC ${_common_include_directories} + qnn_whisper_runner PUBLIC ${_common_include_directories} ) - target_link_libraries( qnn_whisper_runner qnn_executorch_backend @@ -37,9 +35,7 @@ target_link_libraries( tokenizers::tokenizers ) -target_compile_options( - qnn_whisper_runner PUBLIC ${_common_compile_options} -) +target_compile_options(qnn_whisper_runner PUBLIC ${_common_compile_options}) set_target_properties( - qnn_whisper_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" + qnn_whisper_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'" ) diff --git a/examples/qualcomm/qaihub_scripts/llama/CMakeLists.txt b/examples/qualcomm/qaihub_scripts/llama/CMakeLists.txt index 4088d685ec0..b42ceef6eae 100644 --- a/examples/qualcomm/qaihub_scripts/llama/CMakeLists.txt +++ b/examples/qualcomm/qaihub_scripts/llama/CMakeLists.txt @@ -30,8 +30,7 @@ list(PREPEND _qaihub_llama2_7b_runner__srcs add_executable(qaihub_llama2_7b_runner ${_qaihub_llama2_7b_runner__srcs}) target_include_directories( - qaihub_llama2_7b_runner - PUBLIC ${_common_include_directories} + qaihub_llama2_7b_runner PUBLIC ${_common_include_directories} ) target_link_libraries( qaihub_llama2_7b_runner @@ -64,9 +63,7 @@ list(APPEND _common_compile_options -DQAIHUB_LLAMA3_RUNNER) # build qaihub llama3 8b runner add_executable(qaihub_llama3_8b_runner ${_qaihub_llama3_8b_runner__srcs}) target_include_directories( - qaihub_llama3_8b_runner - PUBLIC - ${_common_include_directories} + qaihub_llama3_8b_runner PUBLIC ${_common_include_directories} ) target_link_libraries( diff --git a/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake b/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake index 8e1a478a6cb..ef58f9b4e8d 100644 --- a/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake +++ b/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake @@ -97,10 +97,6 @@ add_compile_options( # -Wall -Wextra -Wcast-align -Wdouble-promotion -Wformat # -Wmissing-field-initializers -Wnull-dereference -Wredundant-decls -Wshadow # -Wswitch -Wswitch-default -Wunused -Wno-redundant-decls - -Wno-stringop-overread - -Wno-error=format= - -Wno-error=maybe-uninitialized - -Wno-error=deprecated-declarations - -Wno-error=shift-count-overflow - -Wno-psabi + -Wno-stringop-overread -Wno-error=format= -Wno-error=maybe-uninitialized + -Wno-error=deprecated-declarations -Wno-error=shift-count-overflow -Wno-psabi ) diff --git a/extension/android/CMakeLists.txt b/extension/android/CMakeLists.txt index feb4fdb6bb9..c1fb1125c3e 100644 --- a/extension/android/CMakeLists.txt +++ b/extension/android/CMakeLists.txt @@ -23,19 +23,19 @@ if(NOT ANDROID_PLATFORM) set(ANDROID_PLATFORM android-30) endif() -# We need to download fbjni library from maven, and use its "prefab" library -# and headers, and link executorch library against that fbjni library. -# We don't know which NDK is used to compile fbjni, and we need to link our -# executorch library to the version which Android APK links against for runtime -# to ensure the libc++ dependencies are consistent. -# WARNING # -# Users need to use the SAME fbjni version here and in app gradle dependency -# for runtime compatibility! +# We need to download fbjni library from maven, and use its "prefab" library and +# headers, and link executorch library against that fbjni library. We don't know +# which NDK is used to compile fbjni, and we need to link our executorch library +# to the version which Android APK links against for runtime to ensure the +# libc++ dependencies are consistent. WARNING # Users need to use the SAME fbjni +# version here and in app gradle dependency for runtime compatibility! if(NOT FBJNI_VERSION) set(FBJNI_VERSION 0.5.1) endif() -set(FBJNI_AAR_URL https://repo1.maven.org/maven2/com/facebook/fbjni/fbjni/${FBJNI_VERSION}/fbjni-${FBJNI_VERSION}.aar) +set(FBJNI_AAR_URL + https://repo1.maven.org/maven2/com/facebook/fbjni/fbjni/${FBJNI_VERSION}/fbjni-${FBJNI_VERSION}.aar +) set(FBJNI_DOWNLOAD_PATH ${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/fbjni.aar) if(NOT EXISTS "${FBJNI_DOWNLOAD_PATH}") @@ -43,25 +43,35 @@ if(NOT EXISTS "${FBJNI_DOWNLOAD_PATH}") endif() add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" - COMMAND unzip -o ${FBJNI_DOWNLOAD_PATH} -d ${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni + OUTPUT + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" + COMMAND unzip -o ${FBJNI_DOWNLOAD_PATH} -d + ${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni DEPENDS "${FBJNI_DOWNLOAD_PATH}" ) add_custom_target( fbjni_prefab - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" + DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" ) add_library(fbjni SHARED IMPORTED) add_dependencies(fbjni fbjni_prefab) -set_target_properties(fbjni PROPERTIES - IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" +set_target_properties( + fbjni + PROPERTIES + IMPORTED_LOCATION + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so" ) executorch_target_link_options_shared_lib(executorch) -add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp) +add_library( + executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp +) set(link_libraries) list( @@ -78,21 +88,14 @@ list( ) if(EXECUTORCH_ANDROID_PROFILING) - list( - APPEND - link_libraries - etdump - flatccrt + list(APPEND link_libraries etdump flatccrt) + target_compile_definitions( + executorch_jni PUBLIC EXECUTORCH_ANDROID_PROFILING=1 ) - target_compile_definitions(executorch_jni PUBLIC EXECUTORCH_ANDROID_PROFILING=1) endif() if(TARGET optimized_native_cpu_ops_lib) - list( - APPEND - link_libraries - optimized_native_cpu_ops_lib - ) + list(APPEND link_libraries optimized_native_cpu_ops_lib) executorch_target_link_options_shared_lib(optimized_native_cpu_ops_lib) else() list(APPEND link_libraries portable_ops_lib portable_kernels) @@ -110,7 +113,15 @@ endif() if(TARGET xnnpack_backend) executorch_target_link_options_shared_lib(xnnpack_backend) - list(APPEND link_libraries xnnpack_backend XNNPACK pthreadpool cpuinfo xnnpack-microkernels-prod) + list( + APPEND + link_libraries + xnnpack_backend + XNNPACK + pthreadpool + cpuinfo + xnnpack-microkernels-prod + ) if(TARGET kleidiai) list(APPEND link_libraries kleidiai) endif() @@ -149,7 +160,9 @@ endif() if(EXECUTORCH_BUILD_EXTENSION_TRAINING) target_sources(executorch_jni PRIVATE jni/jni_layer_training.cpp jni/log.cpp) list(APPEND link_libraries extension_training) - target_compile_definitions(executorch_jni PUBLIC EXECUTORCH_BUILD_EXTENSION_TRAINING=1) + target_compile_definitions( + executorch_jni PUBLIC EXECUTORCH_BUILD_EXTENSION_TRAINING=1 + ) endif() if(EXECUTORCH_BUILD_LLAMA_JNI) @@ -167,32 +180,40 @@ if(EXECUTORCH_BUILD_LLAMA_JNI) ) if(NEURON_BUFFER_ALLOCATOR_LIB) - target_sources( - executorch_jni PRIVATE - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/mtk_llama_runner.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaModelChunk.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaRuntime.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/ModelChunk.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/MultiModelLoader.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/mask_builder.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/rotary_embedding.cpp - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/token_embedding.cpp + target_sources( + executorch_jni + PRIVATE + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/mtk_llama_runner.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaModelChunk.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaRuntime.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/ModelChunk.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/MultiModelLoader.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/mask_builder.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/rotary_embedding.cpp + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/token_embedding.cpp ) target_include_directories( - executorch_jni PRIVATE - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/ - ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner + executorch_jni + PRIVATE ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/ + ${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner ) add_library(libneuron_buffer_allocator SHARED IMPORTED) - set_property(TARGET libneuron_buffer_allocator PROPERTY IMPORTED_LOCATION ${NEURON_BUFFER_ALLOCATOR_LIB}) + set_property( + TARGET libneuron_buffer_allocator PROPERTY IMPORTED_LOCATION + ${NEURON_BUFFER_ALLOCATOR_LIB} + ) list(APPEND link_libraries neuron_backend libneuron_buffer_allocator) - target_compile_definitions(executorch_jni PRIVATE EXECUTORCH_BUILD_MEDIATEK=1) + target_compile_definitions( + executorch_jni PRIVATE EXECUTORCH_BUILD_MEDIATEK=1 + ) endif() endif() target_include_directories( - executorch_jni PRIVATE ${_common_include_directories} - "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" + executorch_jni + PRIVATE + ${_common_include_directories} + "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/" ) target_compile_options(executorch_jni PUBLIC ${_common_compile_options}) diff --git a/extension/apple/CMakeLists.txt b/extension/apple/CMakeLists.txt index 0e978073aa2..180c13777be 100644 --- a/extension/apple/CMakeLists.txt +++ b/extension/apple/CMakeLists.txt @@ -20,36 +20,28 @@ endif() add_library(extension_apple) -file(GLOB OBJC_SOURCES - ExecuTorch/Exported/*.m - ExecuTorch/Exported/*.mm - ExecuTorch/Internal/*.m - ExecuTorch/Internal/*.mm +file(GLOB OBJC_SOURCES ExecuTorch/Exported/*.m ExecuTorch/Exported/*.mm + ExecuTorch/Internal/*.m ExecuTorch/Internal/*.mm ) -file(GLOB SWIFT_SOURCES - ExecuTorch/Exported/*.swift -) +file(GLOB SWIFT_SOURCES ExecuTorch/Exported/*.swift) -target_sources(extension_apple PRIVATE - ${OBJC_SOURCES} - ${SWIFT_SOURCES} -) +target_sources(extension_apple PRIVATE ${OBJC_SOURCES} ${SWIFT_SOURCES}) -target_include_directories(extension_apple +target_include_directories( + extension_apple PUBLIC ExecuTorch/Exported PRIVATE ExecuTorch/Internal ) find_library(FOUNDATION_FRAMEWORK Foundation) -target_link_libraries(extension_apple - PRIVATE executorch ${FOUNDATION_FRAMEWORK} +target_link_libraries( + extension_apple PRIVATE executorch ${FOUNDATION_FRAMEWORK} ) -set_source_files_properties(${OBJC_SOURCES} PROPERTIES COMPILE_FLAGS - "-fobjc-arc" - "-fno-exceptions" - "-fno-rtti" +set_source_files_properties( + ${OBJC_SOURCES} PROPERTIES COMPILE_FLAGS "-fobjc-arc" "-fno-exceptions" + "-fno-rtti" ) set(MODULE_MAP_DIR ${CMAKE_CURRENT_BINARY_DIR}/module) @@ -57,30 +49,36 @@ set(MODULE_MAP_FILE ${MODULE_MAP_DIR}/module.modulemap) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/ExecuTorch/Exported/ExecuTorch.h" - "${MODULE_MAP_DIR}/ExecuTorch.h" - COPYONLY + "${MODULE_MAP_DIR}/ExecuTorch.h" COPYONLY ) file(MAKE_DIRECTORY ${MODULE_MAP_DIR}) -file(WRITE ${MODULE_MAP_FILE} -"module ExecuTorch { +file( + WRITE ${MODULE_MAP_FILE} + "module ExecuTorch { umbrella header \"ExecuTorch.h\" export * } -") +" +) -set(SWIFT_CLANG_INTEROP_FLAGS "-Xcc -fmodule-map-file=${MODULE_MAP_FILE} -I ${MODULE_MAP_DIR}") +set(SWIFT_CLANG_INTEROP_FLAGS + "-Xcc -fmodule-map-file=${MODULE_MAP_FILE} -I ${MODULE_MAP_DIR}" +) set(SWIFT_REMAP_FLAGS "-debug-prefix-map ${PROJECT_SOURCE_DIR}=/executorch") -set_target_properties(extension_apple PROPERTIES - Swift_MODULE_NAME "ExecuTorch" - Swift_FLAGS "${SWIFT_CLANG_INTEROP_FLAGS} ${SWIFT_REMAP_FLAGS}" - XCODE_ATTRIBUTE_SWIFT_MODULE_NAME "ExecuTorch" - XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION "YES" - XCODE_ATTRIBUTE_OTHER_SWIFT_FLAGS "${SWIFT_CLANG_INTEROP_FLAGS} ${SWIFT_REMAP_FLAGS}" +set_target_properties( + extension_apple + PROPERTIES Swift_MODULE_NAME "ExecuTorch" + Swift_FLAGS "${SWIFT_CLANG_INTEROP_FLAGS} ${SWIFT_REMAP_FLAGS}" + XCODE_ATTRIBUTE_SWIFT_MODULE_NAME "ExecuTorch" + XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION "YES" + XCODE_ATTRIBUTE_OTHER_SWIFT_FLAGS + "${SWIFT_CLANG_INTEROP_FLAGS} ${SWIFT_REMAP_FLAGS}" ) add_custom_command( - TARGET extension_apple POST_BUILD + TARGET extension_apple + POST_BUILD COMMAND ${CMAKE_COMMAND} -E rm -rf ${MODULE_MAP_DIR} ) diff --git a/extension/flat_tensor/serialize/CMakeLists.txt b/extension/flat_tensor/serialize/CMakeLists.txt index 39b364797b8..1909bd4de08 100644 --- a/extension/flat_tensor/serialize/CMakeLists.txt +++ b/extension/flat_tensor/serialize/CMakeLists.txt @@ -10,8 +10,12 @@ # ~~~ # The include directory that will contain the generated schema headers. -set(_flat_tensor_schema__include_dir "${CMAKE_BINARY_DIR}/extension/flat_tensor/include") -set(_flat_tensor_schema__output_dir "${_flat_tensor_schema__include_dir}/executorch/extension/flat_tensor/serialize") +set(_flat_tensor_schema__include_dir + "${CMAKE_BINARY_DIR}/extension/flat_tensor/include" +) +set(_flat_tensor_schema__output_dir + "${_flat_tensor_schema__include_dir}/executorch/extension/flat_tensor/serialize" +) # Source root directory for executorch. if(NOT EXECUTORCH_ROOT) set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) @@ -29,9 +33,8 @@ function(generate_flat_tensor_schema _schema_srcs _schema_name) # Generate the headers from the .fbs files. add_custom_command( OUTPUT ${_schema_outputs} - COMMAND - flatc --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o - "${_flat_tensor_schema__output_dir}" ${_schema_srcs} + COMMAND flatc --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o + "${_flat_tensor_schema__output_dir}" ${_schema_srcs} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS flatc ${_schema_srcs} COMMENT "Generating ${_schema_name} headers" @@ -45,7 +48,8 @@ function(generate_flat_tensor_schema _schema_srcs _schema_name) # and some users need an alignment larger than the default, which is typically # 32. target_compile_definitions( - ${_schema_name} INTERFACE FLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT} + ${_schema_name} + INTERFACE FLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT} ) target_include_directories( diff --git a/extension/llm/apple/CMakeLists.txt b/extension/llm/apple/CMakeLists.txt index aa7da842004..1755f09b67f 100644 --- a/extension/llm/apple/CMakeLists.txt +++ b/extension/llm/apple/CMakeLists.txt @@ -43,6 +43,7 @@ set_source_files_properties( "-fno-rtti" ) -set_target_properties(extension_llm_apple PROPERTIES - XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION YES +set_target_properties( + extension_llm_apple PROPERTIES XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION + YES ) diff --git a/extension/module/test/CMakeLists.txt b/extension/module/test/CMakeLists.txt index f5c1fd8d857..964b810eed5 100644 --- a/extension/module/test/CMakeLists.txt +++ b/extension/module/test/CMakeLists.txt @@ -23,9 +23,8 @@ add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte" "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte" "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd" - COMMAND - ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAdd" - --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null + COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules + "ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul" --external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null @@ -60,8 +59,4 @@ et_cxx_test( add_dependencies(extension_module_test generated_module_test_files) set_property(TEST extension_module_test PROPERTY ENVIRONMENT ${test_env}) -set_property( - TEST extension_module_test - PROPERTY ENVIRONMENT - "${test_env}" -) +set_property(TEST extension_module_test PROPERTY ENVIRONMENT "${test_env}") diff --git a/extension/runner_util/test/CMakeLists.txt b/extension/runner_util/test/CMakeLists.txt index 1be569cf4eb..0cca06178cd 100644 --- a/extension/runner_util/test/CMakeLists.txt +++ b/extension/runner_util/test/CMakeLists.txt @@ -19,8 +19,8 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte" - COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAdd" --outdir - "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null + COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules + "ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null WORKING_DIRECTORY ${EXECUTORCH_ROOT} ) @@ -44,5 +44,7 @@ et_cxx_test( portable_ops_lib ) -add_dependencies(extension_runner_util_test executorch_runner_util_test_resources) +add_dependencies( + extension_runner_util_test executorch_runner_util_test_resources +) set_property(TEST extension_runner_util_test PROPERTY ENVIRONMENT ${test_env}) diff --git a/kernels/portable/cpu/util/test/CMakeLists.txt b/kernels/portable/cpu/util/test/CMakeLists.txt index 41bfea54020..33ca3db3125 100644 --- a/kernels/portable/cpu/util/test/CMakeLists.txt +++ b/kernels/portable/cpu/util/test/CMakeLists.txt @@ -21,5 +21,9 @@ et_cxx_test( ) find_package_torch_headers() -target_include_directories(kernels_portable_cpu_util_test PRIVATE ${TORCH_INCLUDE_DIRS}) -target_compile_definitions(kernels_portable_cpu_util_test PRIVATE ET_USE_PYTORCH_HEADERS) +target_include_directories( + kernels_portable_cpu_util_test PRIVATE ${TORCH_INCLUDE_DIRS} +) +target_compile_definitions( + kernels_portable_cpu_util_test PRIVATE ET_USE_PYTORCH_HEADERS +) diff --git a/kernels/test/CMakeLists.txt b/kernels/test/CMakeLists.txt index f5997a1ee3f..680dfb0d28c 100644 --- a/kernels/test/CMakeLists.txt +++ b/kernels/test/CMakeLists.txt @@ -61,7 +61,7 @@ foreach(kernel ${_kernels}) set(_kernel_ops_lib "optimized_native_cpu_ops_lib") set(_kernel_ops_lib_path "${CMAKE_CURRENT_BINARY_DIR}/../../configurations/optimized_native_cpu_ops_lib" - ) + ) elseif(${kernel} STREQUAL "optimized_portable") set(_kernel_ops_lib "${kernel}_ops_lib") set(_kernel_ops_lib_path @@ -312,9 +312,8 @@ if(TARGET optimized_portable_kernels) list(APPEND _optimized_kernels_test_sources ${all_test_sources}) list(REMOVE_DUPLICATES _optimized_kernels_test_sources) - # Make sure that we still test optimized versions of portable - # kernels even if they would currently be shadowed by specific - # optimized implementations. + # Make sure that we still test optimized versions of portable kernels even if + # they would currently be shadowed by specific optimized implementations. et_cxx_test( optimized_portable_kernels_test SOURCES @@ -323,9 +322,10 @@ if(TARGET optimized_portable_kernels) EXTRA_LIBS optimized_portable_kernels ) - add_dependencies(optimized_portable_kernels_test generate_wrapper) + add_dependencies(optimized_portable_kernels_test generate_wrapper) target_include_directories( - optimized_portable_kernels_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/optimized_portable" + optimized_portable_kernels_test + PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/optimized_portable" ) endif() diff --git a/requirements-dev.txt b/requirements-dev.txt index 1743b142a4d..e2a4f8af99e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,4 +9,4 @@ wheel # For building the pip package archive. zstd # Imported by resolve_buck.py. certifi # Imported by resolve_buck.py. lintrunner==0.12.7 -lintrunner-adapters==0.12.4 +lintrunner-adapters==0.12.6 diff --git a/requirements-lintrunner.txt b/requirements-lintrunner.txt index 02b8ab67051..d659185f893 100644 --- a/requirements-lintrunner.txt +++ b/requirements-lintrunner.txt @@ -15,7 +15,8 @@ usort==1.0.8.post1 # Other linters clang-format==18.1.3 +cmakelang==0.6.13 cmakelint==1.4.1 # MyPy -mypy==1.14.1 \ No newline at end of file +mypy==1.14.1 diff --git a/runtime/executor/test/CMakeLists.txt b/runtime/executor/test/CMakeLists.txt index da0198975b4..d8df1f9ea56 100644 --- a/runtime/executor/test/CMakeLists.txt +++ b/runtime/executor/test/CMakeLists.txt @@ -37,8 +37,9 @@ add_custom_command( ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul" --external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" COMMAND - ${PYTHON_EXECUTABLE} -m test.models.export_delegated_program --modules "ModuleAddMul" - --backend_id "StubBackend" --outdir "${CMAKE_CURRENT_BINARY_DIR}/delegated/" || true + ${PYTHON_EXECUTABLE} -m test.models.export_delegated_program --modules + "ModuleAddMul" --backend_id "StubBackend" --outdir + "${CMAKE_CURRENT_BINARY_DIR}/delegated/" || true WORKING_DIRECTORY ${EXECUTORCH_ROOT} ) @@ -161,20 +162,11 @@ target_include_directories( list(TRANSFORM _test_backend_compiler_lib__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library( - test_backend_compiler_lib - STATIC - ${_test_backend_compiler_lib__srcs} + test_backend_compiler_lib STATIC ${_test_backend_compiler_lib__srcs} ) -target_link_libraries( - test_backend_compiler_lib - PUBLIC - executorch_core -) +target_link_libraries(test_backend_compiler_lib PUBLIC executorch_core) executorch_target_link_options_shared_lib(test_backend_compiler_lib) -install( - TARGETS test_backend_compiler_lib - DESTINATION lib -) +install(TARGETS test_backend_compiler_lib DESTINATION lib) diff --git a/runtime/kernel/test/CMakeLists.txt b/runtime/kernel/test/CMakeLists.txt index 5a9c4f0febf..c70ec5d135b 100644 --- a/runtime/kernel/test/CMakeLists.txt +++ b/runtime/kernel/test/CMakeLists.txt @@ -20,7 +20,8 @@ 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_core + 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) @@ -53,7 +54,8 @@ target_compile_definitions( operator_registry_max_kernel_num_test PRIVATE "-DMAX_KERNEL_NUM=1" ) # TODO: This is currently not working! -# add_test(operator_registry_max_kernel_num_test operator_registry_max_kernel_num_test) +# add_test(operator_registry_max_kernel_num_test +# operator_registry_max_kernel_num_test) # TODO: Migrate kernel_double_registration_test and # test_kernel_manual_registration. Make sure dtype selective build is working. diff --git a/runtime/platform/test/CMakeLists.txt b/runtime/platform/test/CMakeLists.txt index 356c05a01e7..901fd0499cd 100644 --- a/runtime/platform/test/CMakeLists.txt +++ b/runtime/platform/test/CMakeLists.txt @@ -19,14 +19,22 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake) et_cxx_test(platform_test SOURCES executor_pal_test.cpp) -et_cxx_test(platform_runtime_override_test SOURCES executor_pal_runtime_override_test.cpp stub_platform.cpp) +et_cxx_test( + platform_runtime_override_test SOURCES executor_pal_runtime_override_test.cpp + stub_platform.cpp +) -et_cxx_test(platform_static_runtime_override_test SOURCES executor_pal_static_runtime_override_test.cpp) +et_cxx_test( + platform_static_runtime_override_test SOURCES + executor_pal_static_runtime_override_test.cpp +) # TODO: Re-enable this test on OSS +# # et_cxx_test(platform_death_test SOURCES executor_pal_death_test.cpp) et_cxx_test(logging_test SOURCES logging_test.cpp) # TODO: Re-enable this test on OSS +# # et_cxx_test(clock_test SOURCES clock_test.cpp stub_platform.cpp) diff --git a/tools/cmake/Codegen.cmake b/tools/cmake/Codegen.cmake index f4005b4a696..0713d6f5d18 100644 --- a/tools/cmake/Codegen.cmake +++ b/tools/cmake/Codegen.cmake @@ -12,7 +12,9 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) function(gen_selected_ops) - set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS OPS_FROM_MODEL DTYPE_SELECTIVE_BUILD) + set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS + OPS_FROM_MODEL DTYPE_SELECTIVE_BUILD + ) cmake_parse_arguments(GEN "" "" "${arg_names}" ${ARGN}) message(STATUS "Generating selected operator lib:") @@ -27,13 +29,14 @@ function(gen_selected_ops) if(GEN_DTYPE_SELECTIVE_BUILD) if(NOT GEN_OPS_FROM_MODEL) - message(FATAL_ERROR " DTYPE_SELECTIVE_BUILD is only support with model API, please pass in a model") + message( + FATAL_ERROR + " DTYPE_SELECTIVE_BUILD is only support with model API, please pass in a model" + ) endif() endif() - set(_oplist_yaml - ${_out_dir}/selected_operators.yaml - ) + set(_oplist_yaml ${_out_dir}/selected_operators.yaml) file(MAKE_DIRECTORY ${_out_dir}) @@ -68,12 +71,10 @@ function(gen_selected_ops) ) if(GEN_DTYPE_SELECTIVE_BUILD) - set(_opvariant_h - ${_out_dir}/selected_op_variants.h - ) - set(_gen_opvariant_command "${PYTHON_EXECUTABLE}" -m codegen.tools.gen_selected_op_variants - --yaml-file=${_oplist_yaml} - --output-dir=${_out_dir}/ + set(_opvariant_h ${_out_dir}/selected_op_variants.h) + set(_gen_opvariant_command + "${PYTHON_EXECUTABLE}" -m codegen.tools.gen_selected_op_variants + --yaml-file=${_oplist_yaml} --output-dir=${_out_dir}/ ) message("Command - ${_gen_opvariant_command}") add_custom_command( @@ -137,7 +138,7 @@ function(generate_bindings_for_kernels) --tags-path=${torchgen-out}/packaged/ATen/native/tags.yaml --aten-yaml-path=${torchgen-out}/packaged/ATen/native/native_functions.yaml --op-selection-yaml-path=${_oplist_yaml} - ) + ) if(GEN_ADD_EXCEPTION_BOUNDARY) set(_gen_command "${_gen_command}" --add-exception-boundary) endif() @@ -162,8 +163,7 @@ function(generate_bindings_for_kernels) OUTPUT ${_gen_command_sources} COMMAND ${_gen_command} DEPENDS ${_oplist_yaml} ${_opvariant_h} ${GEN_CUSTOM_OPS_YAML} - ${GEN_FUNCTIONS_YAML} ${_codegen_templates} - ${_torchgen_srcs} + ${GEN_FUNCTIONS_YAML} ${_codegen_templates} ${_torchgen_srcs} WORKING_DIRECTORY ${EXECUTORCH_ROOT} ) # Make generated file list available in parent scope @@ -216,64 +216,93 @@ function(gen_operators_lib) set(_out_dir ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}) if(GEN_DTYPE_SELECTIVE_BUILD) - set(_opvariant_h - ${_out_dir}/selected_op_variants.h - ) + set(_opvariant_h ${_out_dir}/selected_op_variants.h) endif() add_library(${GEN_LIB_NAME}) - set(_srcs_list - ${_out_dir}/RegisterCodegenUnboxedKernelsEverything.cpp - ${_out_dir}/Functions.h ${_out_dir}/NativeFunctions.h + set(_srcs_list ${_out_dir}/RegisterCodegenUnboxedKernelsEverything.cpp + ${_out_dir}/Functions.h ${_out_dir}/NativeFunctions.h ) if(GEN_DTYPE_SELECTIVE_BUILD) list(APPEND _srcs_list ${_opvariant_h}) endif() - target_sources( - ${GEN_LIB_NAME} - PRIVATE ${_srcs_list} - ) + target_sources(${GEN_LIB_NAME} PRIVATE ${_srcs_list}) target_link_libraries(${GEN_LIB_NAME} PRIVATE ${GEN_DEPS}) set(portable_kernels_check "portable_kernels") if(GEN_KERNEL_LIBS) - set(_common_compile_options -Wno-deprecated-declarations -ffunction-sections -fdata-sections -Os) + set(_common_compile_options -Wno-deprecated-declarations + -ffunction-sections -fdata-sections -Os + ) if(GEN_DTYPE_SELECTIVE_BUILD) if("${portable_kernels_check}" IN_LIST GEN_KERNEL_LIBS) list(REMOVE_ITEM GEN_KERNEL_LIBS ${portable_kernels_check}) - # Build kernels_util_all_deps, since later selected_portable_kernels depends on it - list(TRANSFORM _kernels_util_all_deps__srcs PREPEND "${EXECUTORCH_ROOT}/") - add_library(selected_kernels_util_all_deps ${_kernels_util_all_deps__srcs}) - target_link_libraries(selected_kernels_util_all_deps PRIVATE executorch_core) - target_include_directories(selected_kernels_util_all_deps PUBLIC ${_common_include_directories}) - target_compile_definitions(selected_kernels_util_all_deps PUBLIC C10_USING_CUSTOM_GENERATED_MACROS) - target_compile_options(selected_kernels_util_all_deps PUBLIC ${_common_compile_options}) + # Build kernels_util_all_deps, since later selected_portable_kernels + # depends on it + list(TRANSFORM _kernels_util_all_deps__srcs + PREPEND "${EXECUTORCH_ROOT}/" + ) + add_library( + selected_kernels_util_all_deps ${_kernels_util_all_deps__srcs} + ) + target_link_libraries( + selected_kernels_util_all_deps PRIVATE executorch_core + ) + target_include_directories( + selected_kernels_util_all_deps PUBLIC ${_common_include_directories} + ) + target_compile_definitions( + selected_kernels_util_all_deps + PUBLIC C10_USING_CUSTOM_GENERATED_MACROS + ) + target_compile_options( + selected_kernels_util_all_deps PUBLIC ${_common_compile_options} + ) # Build selected_portable_kernels list(TRANSFORM _portable_kernels__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library(selected_portable_kernels ${_portable_kernels__srcs}) - target_link_libraries(selected_portable_kernels PRIVATE executorch_core selected_kernels_util_all_deps) - target_compile_options(selected_portable_kernels PUBLIC ${_common_compile_options}) - target_include_directories(selected_portable_kernels PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/) + target_link_libraries( + selected_portable_kernels PRIVATE executorch_core + selected_kernels_util_all_deps + ) + target_compile_options( + selected_portable_kernels PUBLIC ${_common_compile_options} + ) + target_include_directories( + selected_portable_kernels + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/ + ) # Make sure the header is generated before compiling the library add_dependencies(selected_portable_kernels ${GEN_LIB_NAME}) - # Create a custom target for the header to ensure proper dependency tracking - add_custom_target(selected_portable_kernels_header DEPENDS ${_opvariant_h}) - add_dependencies(selected_portable_kernels selected_portable_kernels_header) + # Create a custom target for the header to ensure proper dependency + # tracking + add_custom_target( + selected_portable_kernels_header DEPENDS ${_opvariant_h} + ) + add_dependencies( + selected_portable_kernels selected_portable_kernels_header + ) # Apply the compile definition for dtype selective build - target_compile_definitions(selected_portable_kernels PRIVATE EXECUTORCH_SELECTIVE_BUILD_DTYPE=1) + target_compile_definitions( + selected_portable_kernels PRIVATE EXECUTORCH_SELECTIVE_BUILD_DTYPE=1 + ) target_link_libraries(${GEN_LIB_NAME} PUBLIC selected_portable_kernels) else() - message(FATAL_ERROR "Currently dtype selective build is only supported for portable_kernels but {${GEN_KERNEL_LIBS}} were provided!") + message( + FATAL_ERROR + "Currently dtype selective build is only supported for portable_kernels but {${GEN_KERNEL_LIBS}} were provided!" + ) endif() endif() - # After removing portable_kernels, test if there are other kernel libs provided + # After removing portable_kernels, test if there are other kernel libs + # provided if(GEN_KERNEL_LIBS) target_link_libraries(${GEN_LIB_NAME} PUBLIC ${GEN_KERNEL_LIBS}) endif() diff --git a/tools/cmake/common/preset.cmake b/tools/cmake/common/preset.cmake index eca0e2c9d40..4ac45e28562 100644 --- a/tools/cmake/common/preset.cmake +++ b/tools/cmake/common/preset.cmake @@ -26,7 +26,6 @@ function(announce_configured_options NAME) endif() endfunction() - # Print the configured options. function(print_configured_options) get_property(_options GLOBAL PROPERTY _announce_configured_options) @@ -58,7 +57,6 @@ function(print_configured_options) message(STATUS "--------------------------") endfunction() - # Enforce option names to always start with EXECUTORCH. function(enforce_executorch_option_name NAME) if(NOT "${NAME}" MATCHES "^EXECUTORCH_") @@ -66,32 +64,44 @@ function(enforce_executorch_option_name NAME) endif() endfunction() - -# Define an overridable option. -# 1) If the option is already defined in the process, then store that in cache -# 2) If the option is NOT set, then store the default value in cache +# Define an overridable option. 1) If the option is already defined in the +# process, then store that in cache 2) If the option is NOT set, then store the +# default value in cache macro(define_overridable_option NAME DESCRIPTION VALUE_TYPE DEFAULT_VALUE) enforce_executorch_option_name(${NAME}) - if(NOT "${VALUE_TYPE}" STREQUAL "STRING" AND NOT "${VALUE_TYPE}" STREQUAL "BOOL") - message(FATAL_ERROR "Invalid option (${NAME}) value type '${VALUE_TYPE}', must be either STRING or BOOL") + if(NOT "${VALUE_TYPE}" STREQUAL "STRING" AND NOT "${VALUE_TYPE}" STREQUAL + "BOOL" + ) + message( + FATAL_ERROR + "Invalid option (${NAME}) value type '${VALUE_TYPE}', must be either STRING or BOOL" + ) endif() if(DEFINED ${NAME} AND NOT DEFINED CACHE{${NAME}}) - set(${NAME} ${${NAME}} CACHE ${VALUE_TYPE} ${DESCRIPTION} FORCE) + set(${NAME} + ${${NAME}} + CACHE ${VALUE_TYPE} ${DESCRIPTION} FORCE + ) else() - set(${NAME} ${DEFAULT_VALUE} CACHE ${VALUE_TYPE} ${DESCRIPTION}) + set(${NAME} + ${DEFAULT_VALUE} + CACHE ${VALUE_TYPE} ${DESCRIPTION} + ) endif() announce_configured_options(${NAME}) endmacro() - # Set an overridable option. macro(set_overridable_option NAME VALUE) # If the user has explitily set the option, do not override it. if(NOT DEFINED ${NAME}) - set(${NAME} ${VALUE} CACHE STRING "") + set(${NAME} + ${VALUE} + CACHE STRING "" + ) endif() endmacro() @@ -106,16 +116,9 @@ macro(load_build_preset) # try to determine a preset file. endmacro() - # Check if the required options are set. function(check_required_options_on) - cmake_parse_arguments( - ARG - "" - "IF_ON" - "REQUIRES" - ${ARGN} - ) + cmake_parse_arguments(ARG "" "IF_ON" "REQUIRES" ${ARGN}) if(${${ARG_IF_ON}}) foreach(required ${ARG_REQUIRES}) @@ -126,16 +129,9 @@ function(check_required_options_on) endif() endfunction() - # Check if flags conflict with each other. function(check_conflicting_options_on) - cmake_parse_arguments( - ARG - "" - "IF_ON" - "CONFLICTS_WITH" - ${ARGN} - ) + cmake_parse_arguments(ARG "" "IF_ON" "CONFLICTS_WITH" ${ARGN}) if(${${ARG_IF_ON}}) foreach(conflict ${ARG_CONFLICTS_WITH}) diff --git a/tools/cmake/executorch-wheel-config.cmake b/tools/cmake/executorch-wheel-config.cmake index 14abd4333c0..215a20f4d3c 100644 --- a/tools/cmake/executorch-wheel-config.cmake +++ b/tools/cmake/executorch-wheel-config.cmake @@ -15,39 +15,41 @@ # # This will define the following variables: # -# EXECUTORCH_FOUND -- True if the system has the ExecuTorch library -# EXECUTORCH_INCLUDE_DIRS -- The include directories for ExecuTorch -# EXECUTORCH_LIBRARIES -- Libraries to link against +# EXECUTORCH_FOUND -- True if the system has the ExecuTorch library +# EXECUTORCH_INCLUDE_DIRS -- The include directories for ExecuTorch +# EXECUTORCH_LIBRARIES -- Libraries to link against # cmake_minimum_required(VERSION 3.19) -# Find prebuilt _portable_lib..so. This file should be installed under -# /executorch/share/cmake +# Find prebuilt _portable_lib..so. This file should be installed +# under /executorch/share/cmake # Find python -if(DEFINED ENV{CONDA_DEFAULT_ENV} AND NOT $ENV{CONDA_DEFAULT_ENV} STREQUAL "base") - set(PYTHON_EXECUTABLE - python - ) +if(DEFINED ENV{CONDA_DEFAULT_ENV} AND NOT $ENV{CONDA_DEFAULT_ENV} STREQUAL + "base" +) + set(PYTHON_EXECUTABLE python) else() - set(PYTHON_EXECUTABLE - python3 - ) + set(PYTHON_EXECUTABLE python3) endif() # Get the Python version and platform information execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))" - OUTPUT_VARIABLE EXT_SUFFIX - RESULT_VARIABLE SYSCONFIG_RESULT - ERROR_VARIABLE SYSCONFIG_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND ${PYTHON_EXECUTABLE} -c + "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))" + OUTPUT_VARIABLE EXT_SUFFIX + RESULT_VARIABLE SYSCONFIG_RESULT + ERROR_VARIABLE SYSCONFIG_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) if(SYSCONFIG_RESULT EQUAL 0) message(STATUS "Sysconfig extension suffix: ${EXT_SUFFIX}") else() - message(FATAL_ERROR "Failed to retrieve sysconfig config var EXT_SUFFIX: ${SYSCONFIG_ERROR}") + message( + FATAL_ERROR + "Failed to retrieve sysconfig config var EXT_SUFFIX: ${SYSCONFIG_ERROR}" + ) endif() find_library( @@ -60,13 +62,16 @@ set(EXECUTORCH_LIBRARIES) set(EXECUTORCH_FOUND OFF) if(_portable_lib_LIBRARY) set(EXECUTORCH_FOUND ON) - message(STATUS "ExecuTorch portable library is found at ${_portable_lib_LIBRARY}") + message( + STATUS "ExecuTorch portable library is found at ${_portable_lib_LIBRARY}" + ) list(APPEND EXECUTORCH_LIBRARIES _portable_lib) add_library(_portable_lib STATIC IMPORTED) set(EXECUTORCH_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../../include) - set_target_properties(_portable_lib PROPERTIES - IMPORTED_LOCATION "${_portable_lib_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${EXECUTORCH_INCLUDE_DIRS}" - CXX_STANDARD 17 + set_target_properties( + _portable_lib + PROPERTIES IMPORTED_LOCATION "${_portable_lib_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${EXECUTORCH_INCLUDE_DIRS}" + CXX_STANDARD 17 ) endif() diff --git a/tools/cmake/preset/apple_common.cmake b/tools/cmake/preset/apple_common.cmake index 27212a166ed..5f6d65be42c 100644 --- a/tools/cmake/preset/apple_common.cmake +++ b/tools/cmake/preset/apple_common.cmake @@ -4,7 +4,9 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++${CMAKE_CXX_STANDARD}") +set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD + "c++${CMAKE_CXX_STANDARD}" +) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") # Clean up the paths LLDB sees in DWARF. diff --git a/tools/cmake/preset/arm_baremetal.cmake b/tools/cmake/preset/arm_baremetal.cmake index a091fef5b5a..33a12969484 100644 --- a/tools/cmake/preset/arm_baremetal.cmake +++ b/tools/cmake/preset/arm_baremetal.cmake @@ -22,4 +22,4 @@ if("${EXECUTORCH_BUILD_ARM_ETDUMP}") set(FLATCC_ALLOW_WERROR OFF) else() set(EXECUTORCH_ENABLE_EVENT_TRACER OFF) -endif() \ No newline at end of file +endif() diff --git a/tools/cmake/preset/llm.cmake b/tools/cmake/preset/llm.cmake index 2cd890ee1a1..8d4dd46688d 100644 --- a/tools/cmake/preset/llm.cmake +++ b/tools/cmake/preset/llm.cmake @@ -24,10 +24,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Linux-specific code here -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL + "WIN32" +) # Windows or other OS-specific code here elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") # Android-specific code here else() - message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for LLM: ${CMAKE_SYSTEM_NAME}") + message( + FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for LLM: ${CMAKE_SYSTEM_NAME}" + ) endif() diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index e52317bf452..e13fe026ef2 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -23,13 +23,16 @@ set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_overridable_option(EXECUTORCH_BUILD_COREML ON) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set_overridable_option(EXECUTORCH_BUILD_COREML ON) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32") +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}") + message( + FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for pybind: ${CMAKE_SYSTEM_NAME}" + ) endif() diff --git a/tools/cmake/preset/zephyr.cmake b/tools/cmake/preset/zephyr.cmake index f810b9cc96c..651e3e0b3c6 100644 --- a/tools/cmake/preset/zephyr.cmake +++ b/tools/cmake/preset/zephyr.cmake @@ -1,33 +1,32 @@ - # 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_COREML OFF) -set_overridable_option(EXECUTORCH_ENABLE_EVENT_TRACER OFF) -set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM OFF) -set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM_AOT OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING OFF) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE OFF) -set_overridable_option(EXECUTORCH_BUILD_MPS OFF) -set_overridable_option(EXECUTORCH_BUILD_NEURON OFF) -set_overridable_option(EXECUTORCH_BUILD_OPENVINO OFF) -set_overridable_option(EXECUTORCH_BUILD_PYBIND OFF) -set_overridable_option(EXECUTORCH_BUILD_QNN OFF) -set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED OFF) -set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED OFF) -set_overridable_option(EXECUTORCH_BUILD_DEVTOOLS OFF) -set_overridable_option(EXECUTORCH_BUILD_TESTS OFF) -set_overridable_option(EXECUTORCH_BUILD_XNNPACK OFF) -set_overridable_option(EXECUTORCH_BUILD_VULKAN OFF) -set_overridable_option(EXECUTORCH_BUILD_PORTABLE_OPS ON) -set_overridable_option(EXECUTORCH_BUILD_CADENCE OFF) -set_overridable_option(EXECUTORCH_BUILD_PTHREADPOOL OFF) -set_overridable_option(EXECUTORCH_BUILD_CPUINFO OFF) -set_overridable_option(EXECUTORCH_USE_CPP_CODE_COVERAGE OFF) +set_overridable_option(EXECUTORCH_BUILD_COREML OFF) +set_overridable_option(EXECUTORCH_ENABLE_EVENT_TRACER OFF) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM OFF) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM_AOT OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING OFF) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE OFF) +set_overridable_option(EXECUTORCH_BUILD_MPS OFF) +set_overridable_option(EXECUTORCH_BUILD_NEURON OFF) +set_overridable_option(EXECUTORCH_BUILD_OPENVINO OFF) +set_overridable_option(EXECUTORCH_BUILD_PYBIND OFF) +set_overridable_option(EXECUTORCH_BUILD_QNN OFF) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED OFF) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED OFF) +set_overridable_option(EXECUTORCH_BUILD_DEVTOOLS OFF) +set_overridable_option(EXECUTORCH_BUILD_TESTS OFF) +set_overridable_option(EXECUTORCH_BUILD_XNNPACK OFF) +set_overridable_option(EXECUTORCH_BUILD_VULKAN OFF) +set_overridable_option(EXECUTORCH_BUILD_PORTABLE_OPS ON) +set_overridable_option(EXECUTORCH_BUILD_CADENCE OFF) +set_overridable_option(EXECUTORCH_BUILD_PTHREADPOOL OFF) +set_overridable_option(EXECUTORCH_BUILD_CPUINFO OFF) +set_overridable_option(EXECUTORCH_USE_CPP_CODE_COVERAGE OFF)