Skip to content
Merged
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
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,19 @@ 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
)

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()
Expand Down
108 changes: 55 additions & 53 deletions backends/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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}
)
Loading
Loading