Skip to content

Commit 8e85857

Browse files
authored
Add cmake-format linter (#12868)
This uses the adapter I added to lintrunner-adapters in justinchuby/lintrunner-adapters#117, which was released in the newest lintrunner-adapters release.
1 parent 650b32f commit 8e85857

File tree

57 files changed

+669
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+669
-580
lines changed

.lintrunner.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,36 @@ init_command = [
136136
'--requirement=requirements-lintrunner.txt',
137137
]
138138

139+
[[linter]]
140+
code = 'CMAKEFORMAT'
141+
include_patterns = [
142+
"**/*.cmake",
143+
"**/*.cmake.in",
144+
"**/CMakeLists.txt",
145+
]
146+
exclude_patterns = [
147+
'third-party/**',
148+
'**/third-party/**',
149+
]
150+
command = [
151+
'python',
152+
'-m',
153+
'lintrunner_adapters',
154+
'run',
155+
'cmake_format_linter',
156+
'--',
157+
'@{{PATHSFILE}}',
158+
]
159+
init_command = [
160+
'python',
161+
'-m',
162+
'lintrunner_adapters',
163+
'run',
164+
'pip_init',
165+
'--dry-run={{DRYRUN}}',
166+
'--requirement=requirements-lintrunner.txt',
167+
]
168+
139169
[[linter]]
140170
code = 'ETCAPITAL'
141171
include_patterns = [

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,19 @@ if(EXECUTORCH_BUILD_KERNELS_TORCHAO)
284284
set(TORCHAO_BUILD_CPU_AARCH64 ON)
285285
set(TORCHAO_ENABLE_ARM_NEON_DOT ON)
286286

287-
list(APPEND TORCHAO_INCLUDE_DIRS
287+
list(
288+
APPEND
289+
TORCHAO_INCLUDE_DIRS
288290
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
289291
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
290292
${EXECUTORCH_ROOT}/third-party/ao
291293
)
292294

293295
set(EXECUTORCH_INCLUDE_DIRS ${TORCHAO_INCLUDE_DIRS})
294296

295-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental)
297+
add_subdirectory(
298+
${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental
299+
)
296300
executorch_target_link_options_shared_lib(torchao_ops_executorch)
297301
list(APPEND _executorch_kernels torchao_ops_executorch)
298302
endif()

backends/arm/CMakeLists.txt

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,69 +19,71 @@ set(_common_include_directories
1919
)
2020
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
2121

22-
2322
# bare metal backend builds
2423
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
2524

26-
add_compile_options("-Wall" "-Werror")
25+
add_compile_options("-Wall" "-Werror")
2726

28-
# Third-party folder and Ethos-U driver inclued
29-
set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
30-
set(DRIVER_ETHOSU_INCLUDE_DIR "${THIRD_PARTY_ROOT}/ethos-u-core-driver/include")
31-
include_directories(${DRIVER_ETHOSU_INCLUDE_DIR})
27+
# Third-party folder and Ethos-U driver inclued
28+
set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
29+
set(DRIVER_ETHOSU_INCLUDE_DIR
30+
"${THIRD_PARTY_ROOT}/ethos-u-core-driver/include"
31+
)
32+
include_directories(${DRIVER_ETHOSU_INCLUDE_DIR})
3233

33-
set(_arm_baremetal_sources backends/arm/runtime/EthosUBackend.cpp
34-
backends/arm/runtime/VelaBinStream.cpp
35-
)
36-
list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/")
34+
set(_arm_baremetal_sources backends/arm/runtime/EthosUBackend.cpp
35+
backends/arm/runtime/VelaBinStream.cpp
36+
)
37+
list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/")
3738

38-
add_library(executorch_delegate_ethos_u STATIC ${_arm_baremetal_sources})
39-
target_link_libraries(
40-
executorch_delegate_ethos_u PUBLIC executorch_core ethosu_core_driver
41-
)
39+
add_library(executorch_delegate_ethos_u STATIC ${_arm_baremetal_sources})
40+
target_link_libraries(
41+
executorch_delegate_ethos_u PUBLIC executorch_core ethosu_core_driver
42+
)
4243

43-
install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets)
44+
install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets)
4445

45-
# end config for bare metal builds
46+
# end config for bare metal builds
4647
endif()
4748

48-
49-
# VGF backend builds
49+
# VGF backend builds
5050
if(EXECUTORCH_BUILD_VGF)
5151

52-
# include libvgf
53-
set(LIBVGF_PATH "${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/")
54-
55-
set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party)
56-
set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include)
57-
set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk)
58-
59-
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
60-
set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/")
61-
62-
add_library(vgf STATIC IMPORTED)
63-
set_property( TARGET vgf PROPERTY IMPORTED_LOCATION "${LIBVGF_STATIC}" )
64-
target_include_directories(vgf INTERFACE "${LIBVGF_INCLUDE}")
65-
66-
# Add backend delegate for VGF
67-
set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp
68-
backends/arm/runtime/VGFSetup.cpp )
69-
70-
# vgf backend
71-
list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/")
72-
add_library(vgf_backend ${_vgf_backend_sources})
73-
target_include_directories(
74-
vgf_backend PUBLIC
75-
${_common_include_directories}
76-
${VULKAN_HEADERS_PATH}
77-
${VOLK_HEADERS_PATH}
78-
)
79-
target_compile_options(vgf_backend PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK)
80-
81-
82-
target_link_libraries(vgf_backend PRIVATE executorch_core)
83-
target_link_libraries(vgf_backend PRIVATE vgf)
84-
executorch_target_link_options_shared_lib(vgf_backend)
85-
86-
# end config for VGF builds
52+
# include libvgf
53+
set(LIBVGF_PATH
54+
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/"
55+
)
56+
57+
set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party)
58+
set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include)
59+
set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk)
60+
61+
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
62+
set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/")
63+
64+
add_library(vgf STATIC IMPORTED)
65+
set_property(TARGET vgf PROPERTY IMPORTED_LOCATION "${LIBVGF_STATIC}")
66+
target_include_directories(vgf INTERFACE "${LIBVGF_INCLUDE}")
67+
68+
# Add backend delegate for VGF
69+
set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp
70+
backends/arm/runtime/VGFSetup.cpp
71+
)
72+
73+
# vgf backend
74+
list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/")
75+
add_library(vgf_backend ${_vgf_backend_sources})
76+
target_include_directories(
77+
vgf_backend PUBLIC ${_common_include_directories} ${VULKAN_HEADERS_PATH}
78+
${VOLK_HEADERS_PATH}
79+
)
80+
target_compile_options(
81+
vgf_backend PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK
82+
)
83+
84+
target_link_libraries(vgf_backend PRIVATE executorch_core)
85+
target_link_libraries(vgf_backend PRIVATE vgf)
86+
executorch_target_link_options_shared_lib(vgf_backend)
87+
88+
# end config for VGF builds
8789
endif()

backends/cadence/CMakeLists.txt

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ endif()
2222
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2323

2424
# Let files say "include <executorch/path/to/header.h>".
25-
set(_common_include_directories ${EXECUTORCH_ROOT}/..
26-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
25+
set(_common_include_directories
26+
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
27+
)
2728

2829
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
2930

@@ -38,52 +39,58 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER)
3839
executorch_target_link_options_shared_lib(executorch)
3940
executorch_target_link_options_shared_lib(portable_ops_lib)
4041

41-
target_include_directories(executorch INTERFACE ${_common_include_directories})
42+
target_include_directories(
43+
executorch INTERFACE ${_common_include_directories}
44+
)
4245

4346
find_package(
44-
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party
47+
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party
4548
)
4649

47-
add_executable(cadence_runner
48-
${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp
50+
add_executable(
51+
cadence_runner
52+
${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp
4953
)
5054
target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)
5155

5256
target_include_directories(
53-
etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include
54-
${EXECUTORCH_ROOT}/third-party/flatcc/include
57+
etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include
58+
${EXECUTORCH_ROOT}/third-party/flatcc/include
5559
)
5660

5761
target_include_directories(
58-
cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
59-
${_common_include_directories}
62+
cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
63+
${_common_include_directories}
6064
)
6165

6266
target_link_libraries(
63-
cadence_runner
64-
executorch
65-
gflags
66-
etdump
67-
extension_data_loader
68-
bundled_program
69-
cadence_ops_lib
70-
flatccrt
67+
cadence_runner
68+
executorch
69+
gflags
70+
etdump
71+
extension_data_loader
72+
bundled_program
73+
cadence_ops_lib
74+
flatccrt
7175
)
7276
endif()
7377

7478
if(EXECUTORCH_NNLIB_OPT)
7579
set(TARGET_DIR hifi)
76-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
77-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
80+
add_subdirectory(
81+
${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
82+
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
83+
)
7884
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)
7985
elseif(EXECUTORCH_FUSION_G3_OPT)
8086
set(TARGET_DIR fusion_g3)
81-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
82-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
87+
add_subdirectory(
88+
${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
89+
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
90+
)
8391
else()
8492
set(TARGET_DIR reference)
8593
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)
8694
endif()
8795

88-
8996
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/operators)

backends/cadence/cadence.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-clang++)
4343

4444
set(CMAKE_C_FLAGS_INIT "-stdlib=libc++ -mtext-section-literals -mlongcalls")
4545
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++ -mtext-section-literals -mlongcalls")
46-
#workaround for larger compilation time
46+
# workaround for larger compilation time
4747
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -fno-strict-aliasing")
4848

4949
set(CMAKE_SYSROOT ${TOOLCHAIN_HOME}/${SYSROOT_TARGET})

backends/cadence/fusion_g3/operators/CMakeLists.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,20 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch)
6969
target_link_libraries(aten_ops_cadence PRIVATE xa_nnlib)
7070

7171
# Let files say "include <executorch/path/to/header.h>".
72-
set(_common_include_directories ${EXECUTORCH_ROOT}/..
73-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
72+
set(_common_include_directories
73+
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
74+
)
7475

7576
target_include_directories(
76-
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
77-
${_common_include_directories}
78-
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/
79-
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include/nnlib
80-
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include
81-
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/kernels/tables/include
77+
aten_ops_cadence
78+
PUBLIC
79+
${ROOT_DIR}/..
80+
${CMAKE_BINARY_DIR}
81+
${_common_include_directories}
82+
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/
83+
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include/nnlib
84+
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include
85+
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/kernels/tables/include
8286
)
8387

8488
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
@@ -93,6 +97,4 @@ generate_bindings_for_kernels(
9397
)
9498
message("Generated files ${gen_command_sources}")
9599

96-
gen_operators_lib(
97-
LIB_NAME "cadence_ops_lib" KERNEL_LIBS DEPS aten_ops_cadence
98-
)
100+
gen_operators_lib(LIB_NAME "cadence_ops_lib" KERNEL_LIBS DEPS aten_ops_cadence)

backends/cadence/hifi/kernels/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ add_library(
2828
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_transpose_32.c
2929
)
3030
# Let files say "include <executorch/path/to/header.h>".
31-
set(_common_include_directories ${EXECUTORCH_ROOT}/..
32-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
31+
set(_common_include_directories
32+
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
33+
)
3334

3435
target_include_directories(
3536
cadence_kernels
@@ -39,7 +40,7 @@ target_include_directories(
3940
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include/nnlib
4041
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include
4142
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/ndsp/hifi4/include/
42-
${_common_include_directories}
43+
${_common_include_directories}
4344
)
4445

4546
target_link_libraries(cadence_kernels PRIVATE xa_nnlib)

backends/cadence/hifi/operators/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ set(_aten_ops__srcs
7272
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/select_copy_util.cpp"
7373
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/slice_util.cpp"
7474
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/delinearize_index.cpp"
75-
)
75+
)
7676
add_library(aten_ops_cadence ${_aten_ops__srcs})
7777
target_link_libraries(aten_ops_cadence PUBLIC executorch)
7878
target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels)
7979

8080
# Let files say "include <executorch/path/to/header.h>".
81-
set(_common_include_directories ${EXECUTORCH_ROOT}/..
82-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
81+
set(_common_include_directories
82+
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
83+
)
8384

8485
target_include_directories(
8586
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
@@ -88,9 +89,15 @@ target_include_directories(
8889

8990
# Custom ops that are needed to run the test model.
9091
add_library(
91-
custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp" "op_quantized_matmul_out.cpp"
92-
"op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp"
93-
"op_quantized_conv_out.cpp" "op_quantized_fully_connected_out"
92+
custom_ops
93+
"op_quantized_linear_out.cpp"
94+
"op_quantized_layer_norm.cpp"
95+
"op_quantized_matmul_out.cpp"
96+
"op_quantize_per_tensor.cpp"
97+
"op_quantized_relu_out.cpp"
98+
"op_dequantize_per_tensor.cpp"
99+
"op_quantized_conv_out.cpp"
100+
"op_quantized_fully_connected_out"
94101
)
95102
target_include_directories(
96103
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}

backends/cadence/reference/kernels/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
add_library(cadence_kernels kernels.cpp)
99

1010
# Let files say "include <executorch/path/to/header.h>".
11-
set(_common_include_directories ${EXECUTORCH_ROOT}/..
12-
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
11+
set(_common_include_directories
12+
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
13+
)
1314

14-
target_include_directories(cadence_kernels PUBLIC .
15-
${_common_include_directories}
15+
target_include_directories(
16+
cadence_kernels PUBLIC . ${_common_include_directories}
1617
)

0 commit comments

Comments
 (0)