Skip to content

Add cmake-format linter #12868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 3 additions & 1 deletion backends/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ add_compile_options("-Wall" "-Werror")

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)

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)

# Third-party folder and Ethos-U driver inclued
Expand Down
53 changes: 30 additions & 23 deletions backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ endif()
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)

# Let files say "include <executorch/path/to/header.h>".
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)

Expand All @@ -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)
2 changes: 1 addition & 1 deletion backends/cadence/cadence.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
24 changes: 13 additions & 11 deletions backends/cadence/fusion_g3/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <executorch/path/to/header.h>".
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
Expand All @@ -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)
7 changes: 4 additions & 3 deletions backends/cadence/hifi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ add_library(
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_transpose_32.c
)
# Let files say "include <executorch/path/to/header.h>".
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
Expand All @@ -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)
19 changes: 13 additions & 6 deletions backends/cadence/hifi/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <executorch/path/to/header.h>".
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}
Expand All @@ -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}
Expand Down
9 changes: 5 additions & 4 deletions backends/cadence/reference/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
add_library(cadence_kernels kernels.cpp)

# Let files say "include <executorch/path/to/header.h>".
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}
)
5 changes: 3 additions & 2 deletions backends/cadence/reference/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <executorch/path/to/header.h>".
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}
Expand Down
7 changes: 4 additions & 3 deletions backends/cortex_m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Kernel library for Cortex-M operators. Please keep this file formatted by running:
# Kernel library for Cortex-M operators. Please keep this file formatted by
# running:
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
Expand All @@ -29,8 +30,8 @@ set(_cortex_m_kernels__srcs
${CMAKE_CURRENT_SOURCE_DIR}/ops/op_dequantize_per_tensor.cpp
)

# Generate C++ bindings to register kernels into Executorch (for runtime).
# Here select all ops in operators.yaml
# Generate C++ bindings to register kernels into Executorch (for runtime). Here
# select all ops in operators.yaml
set(_yaml_file ${CMAKE_CURRENT_LIST_DIR}/ops/operators.yaml)
gen_selected_ops(LIB_NAME "cortex_m_ops_lib" OPS_SCHEMA_YAML "${_yaml_file}")

Expand Down
13 changes: 7 additions & 6 deletions backends/mediatek/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ target_link_libraries(
)
target_sources(
neuron_backend
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronBackend.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronBufferAllocator.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronExecutor.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronLog.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/api/APUWareUtilsLib.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/api/NeuronAdapterShim.h>
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronBackend.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronBufferAllocator.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronExecutor.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/NeuronLog.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/api/APUWareUtilsLib.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/runtime/include/api/NeuronAdapterShim.h>
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronBackend.cpp
${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronExecutor.cpp
${CMAKE_CURRENT_LIST_DIR}/runtime/NeuronBufferAllocator.cpp
Expand Down
9 changes: 4 additions & 5 deletions backends/nxp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
50 changes: 28 additions & 22 deletions backends/openvino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading
Loading