Skip to content

Commit

Permalink
Format cmake files. (#4958)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #4958

```
find . -name 'CMakeLists.txt' -o -name '*.cmake' | xargs cmake-format -i
```

Reviewed By: kirklandsign

Differential Revision: D61944289
  • Loading branch information
shoumikhin authored and facebook-github-bot committed Aug 29, 2024
1 parent 1899d15 commit 21dc4d6
Show file tree
Hide file tree
Showing 34 changed files with 462 additions and 518 deletions.
76 changes: 38 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE)
)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
# For dladdr()
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl)
endif()
target_include_directories(
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
Expand Down Expand Up @@ -541,7 +542,7 @@ target_link_options_shared_lib(executorch)
# operators necessary for the models that will run.
#
if(BUILD_EXECUTORCH_PORTABLE_OPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/portable)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/portable)
endif()

if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
Expand Down Expand Up @@ -584,56 +585,56 @@ if(EXECUTORCH_BUILD_GTESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest)
endif()

if(EXECUTORCH_BUILD_SDK)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
ON
CACHE BOOL "EXECUTORCH_BUILD_EXTENSION_DATA_LOADER" FORCE
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/devtools)
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
endif()

if(EXECUTORCH_BUILD_EXTENSION_APPLE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/apple)
if(EXECUTORCH_BUILD_CADENCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/cadence)
endif()

if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
if(EXECUTORCH_BUILD_COREML)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
endif()

if(EXECUTORCH_BUILD_EXTENSION_MODULE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
if(EXECUTORCH_BUILD_MPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
endif()

if(EXECUTORCH_BUILD_NEURON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/mediatek)
endif()

if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
if(EXECUTORCH_BUILD_QNN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
endif()

if(EXECUTORCH_BUILD_QNN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
if(EXECUTORCH_BUILD_SDK)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
ON
CACHE BOOL "EXECUTORCH_BUILD_EXTENSION_DATA_LOADER" FORCE
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/devtools)
endif()

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
if(EXECUTORCH_BUILD_EXTENSION_APPLE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/apple)
endif()

if(EXECUTORCH_BUILD_MPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
endif()

if(EXECUTORCH_BUILD_COREML)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
endif()

if(EXECUTORCH_BUILD_CADENCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/cadence)
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
endif()

if(EXECUTORCH_BUILD_PYBIND)
Expand Down Expand Up @@ -690,9 +691,8 @@ if(EXECUTORCH_BUILD_PYBIND)
)
# util lib
add_library(
util
${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
util ${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
)
target_include_directories(
util PUBLIC ${_common_include_directories} ${TORCH_INCLUDE_DIRS}
Expand Down Expand Up @@ -741,12 +741,14 @@ if(EXECUTORCH_BUILD_PYBIND)
else()
set_target_properties(
portable_lib
PROPERTIES # Assume <executorch> is the root `site-packages/executorch`
# Need to add <executorch>/extension/llm/custom_ops for
# libcustom_ops_aot_lib
# Need to add <executorch>/kernels/quantized for
# libquantized_ops_aot_lib
BUILD_RPATH "$ORIGIN:$ORIGIN/../../extension/llm/custom_ops:$ORIGIN/../../kernels/quantized"
PROPERTIES
# Assume <executorch> is the root `site-packages/executorch`
# Need to add <executorch>/extension/llm/custom_ops for
# libcustom_ops_aot_lib
# Need to add <executorch>/kernels/quantized for
# libquantized_ops_aot_lib
BUILD_RPATH
"$ORIGIN:$ORIGIN/../../extension/llm/custom_ops:$ORIGIN/../../kernels/quantized"
)
endif()

Expand All @@ -757,9 +759,7 @@ endif()

if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
# TODO: move all custom kernels to ${CMAKE_CURRENT_SOURCE_DIR}/kernels/custom
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/custom_ops
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/custom_ops)
endif()

if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
Expand Down
6 changes: 3 additions & 3 deletions backends/apple/coreml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ if(NOT EXECUTORCH_ROOT)
endif()

if(EXECUTORCH_BUILD_SDK)
# protobuf requires frtti
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -frtti" )
# protobuf requires frtti
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -frtti")
endif()

option(COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." OFF)

# inmemoryfs sources
Expand Down
6 changes: 3 additions & 3 deletions backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(TARGET_DIR reference)

if(EXECUTORCH_NNLIB_OPT)
set(TARGET_DIR hifi)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)
set(TARGET_DIR hifi)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -68,7 +68,7 @@ target_include_directories(

target_include_directories(
cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
${_common_include_directories}
${_common_include_directories}
)

target_link_libraries(
Expand Down
11 changes: 6 additions & 5 deletions backends/cadence/hifi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ add_library(

target_include_directories(
cadence_kernels
PUBLIC .
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/common/include/
${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/
PUBLIC
.
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/common/include/
${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/
)

target_link_libraries(cadence_kernels PRIVATE xa_nnlib)
32 changes: 17 additions & 15 deletions backends/cadence/hifi/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,29 @@ set(_aten_ops__srcs
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_sub.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_to_copy.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_view_copy.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_where.cpp")
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_where.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}/..)

target_include_directories(aten_ops_cadence PUBLIC ${ROOT_DIR}/..
${CMAKE_BINARY_DIR}
${_common_include_directories})
target_include_directories(
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

# Custom ops that are needed to run the test model.
add_library(
custom_ops "quantized_linear_out.cpp"
"quantized_layer_norm.cpp"
"quantize_per_tensor.cpp" "dequantize_per_tensor.cpp")
target_include_directories(custom_ops PUBLIC ${ROOT_DIR}/..
${CMAKE_BINARY_DIR}
${_common_include_directories})
custom_ops "quantized_linear_out.cpp" "quantized_layer_norm.cpp"
"quantize_per_tensor.cpp" "dequantize_per_tensor.cpp"
)
target_include_directories(
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

target_link_libraries(custom_ops PUBLIC executorch)
target_link_libraries(custom_ops PRIVATE cadence_kernels)
Expand All @@ -75,12 +78,11 @@ gen_selected_ops(
"${CMAKE_CURRENT_LIST_DIR}/../../aot/functions_hifi.yaml" "" ""
)
generate_bindings_for_kernels(
LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML
FUNCTIONS_YAML ${CMAKE_CURRENT_SOURCE_DIR}/../../aot/functions_hifi.yaml
LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML FUNCTIONS_YAML
${CMAKE_CURRENT_SOURCE_DIR}/../../aot/functions_hifi.yaml
)
message("Generated files ${gen_command_sources}")

gen_operators_lib(
LIB_NAME "cadence_ops_lib"
KERNEL_LIBS custom_ops
DEPS aten_ops_cadence)
LIB_NAME "cadence_ops_lib" KERNEL_LIBS custom_ops DEPS aten_ops_cadence
)
31 changes: 10 additions & 21 deletions backends/cadence/hifi/third-party/nnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@

cmake_minimum_required(VERSION 3.10.0)
project(cadence_nnlib)


add_custom_target( nnlib_target ALL COMMAND
make install_nnlib -f makefile -C ${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/build
OBJDIR=${CMAKE_CURRENT_BINARY_DIR}/obj
LIBDIR=${CMAKE_CURRENT_BINARY_DIR}/lib
-j8 )
add_custom_target(
nnlib_target ALL
COMMAND
make install_nnlib -f makefile -C
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/build
OBJDIR=${CMAKE_CURRENT_BINARY_DIR}/obj
LIBDIR=${CMAKE_CURRENT_BINARY_DIR}/lib -j8
)

add_library(xa_nnlib STATIC IMPORTED GLOBAL)
add_dependencies(xa_nnlib nnlib_target)

set_property(
TARGET xa_nnlib
PROPERTY
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib/xa_nnlib.a"
TARGET xa_nnlib PROPERTY IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/lib/xa_nnlib.a"
)











10 changes: 2 additions & 8 deletions backends/cadence/reference/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
# LICENSE file in the root directory of this source tree.

# lint_cmake: -linelength
add_library(
cadence_kernels
kernels.cpp
)
add_library(cadence_kernels kernels.cpp)

target_include_directories(
cadence_kernels
PUBLIC .
)
target_include_directories(cadence_kernels PUBLIC .)
39 changes: 23 additions & 16 deletions backends/cadence/reference/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,35 @@ set(_aten_ops__srcs
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_where.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_expand_copy.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_gelu.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_empty.cpp")
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_empty.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}/..)

target_include_directories(aten_ops_cadence PUBLIC ${ROOT_DIR}/..
${CMAKE_BINARY_DIR}
${_common_include_directories})
target_include_directories(
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

# Custom ops that are needed to run the test model.
add_library(
custom_ops "quantized_linear_out.cpp" "quantized_conv_out.cpp"
"quantized_relu_out.cpp" "quantized_layer_norm.cpp"
"quantize_per_tensor.cpp" "dequantize_per_tensor.cpp"
"quantized_matmul_out.cpp")
target_include_directories(custom_ops PUBLIC ${ROOT_DIR}/..
${CMAKE_BINARY_DIR}
${_common_include_directories})
custom_ops
"quantized_linear_out.cpp"
"quantized_conv_out.cpp"
"quantized_relu_out.cpp"
"quantized_layer_norm.cpp"
"quantize_per_tensor.cpp"
"dequantize_per_tensor.cpp"
"quantized_matmul_out.cpp"
)
target_include_directories(
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

target_link_libraries(custom_ops PUBLIC executorch)
target_link_libraries(custom_ops PRIVATE cadence_kernels)
Expand All @@ -82,12 +90,11 @@ gen_selected_ops(
"${CMAKE_CURRENT_LIST_DIR}/../../aot/functions.yaml" "" ""
)
generate_bindings_for_kernels(
LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML
FUNCTIONS_YAML ${CMAKE_CURRENT_SOURCE_DIR}/../../aot/functions.yaml
LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML FUNCTIONS_YAML
${CMAKE_CURRENT_SOURCE_DIR}/../../aot/functions.yaml
)
message("Generated cadence x86 files ${gen_command_sources}")

gen_operators_lib(
LIB_NAME "cadence_ops_lib"
KERNEL_LIBS custom_ops
DEPS aten_ops_cadence)
LIB_NAME "cadence_ops_lib" KERNEL_LIBS custom_ops DEPS aten_ops_cadence
)
Loading

0 comments on commit 21dc4d6

Please sign in to comment.