Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .ci/scripts/unittest-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")

if [[ "$BUILD_TOOL" == "cmake" && -z "${EXECUTORCH_CMAKE_SOURCE_DIR:-}" ]]; then
exec bash test/test_worktree_build.sh "$0" "$@"
fi

# The generic Linux job chooses to use base env, not the one setup by the image
eval "$(conda shell.bash hook)"
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
Expand Down
7 changes: 6 additions & 1 deletion .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ build_executorch_runner_cmake() {
-DCMAKE_BUILD_TYPE="${build_type}" \
${sanitizer_flag} \
${CMAKE_ARGS:-} \
-B${CMAKE_OUTPUT_DIR} .
-B${CMAKE_OUTPUT_DIR} "${EXECUTORCH_CMAKE_SOURCE_DIR:-.}"

if [[ -n "${EXECUTORCH_CMAKE_SOURCE_DIR:-}" ]]; then
test "${CMAKE_OUTPUT_DIR}/executorch_source_include/executorch" \
-ef "${EXECUTORCH_CMAKE_SOURCE_DIR}"
fi

if [ "$(uname)" == "Darwin" ]; then
CMAKE_JOBS=$(( $(sysctl -n hw.ncpu) - 1 ))
Expand Down
20 changes: 5 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ include(CMakeDependentOption)
include(ExternalProject)
include(GNUInstallDirs)

executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
Expand Down Expand Up @@ -523,22 +527,8 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
list(APPEND _common_compile_options $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fPIC>)
endif()

# Let files say "include <executorch/path/to/header.h>".
# TODO(#6475): This requires/assumes that the repo lives in a directory named
# exactly `executorch`. Check the assumption first. Remove this check once we
# stop relying on the assumption.
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME _repo_dir_name)
if(NOT "${_repo_dir_name}" STREQUAL "executorch")
message(
FATAL_ERROR
"The ExecuTorch repo must be cloned into a directory named exactly "
"`executorch`; found `${_repo_dir_name}`. See "
"https://github.com/pytorch/executorch/issues/6475 for progress on a "
"fix for this restriction."
)
endif()
set(_common_include_directories
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<BUILD_INTERFACE:${EXECUTORCH_SOURCE_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type/c10>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
Expand Down
7 changes: 5 additions & 2 deletions backends/aoti/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ endif()

# Use ExecuTorch's standard way to find PyTorch libraries for AOTI
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)
find_package_torch()

# ==============================================================================
Expand All @@ -34,7 +37,7 @@ add_library(aoti_common STATIC ${_aoti_common_sources})
target_include_directories(
aoti_common
PUBLIC $<BUILD_INTERFACE:${EXECUTORCH_ROOT}> $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${EXECUTORCH_ROOT}/..>
$<BUILD_INTERFACE:${EXECUTORCH_SOURCE_INCLUDE_DIR}>
)
target_compile_options(
aoti_common
Expand Down Expand Up @@ -73,7 +76,7 @@ add_library(slimtensor INTERFACE)
target_include_directories(
slimtensor
INTERFACE $<BUILD_INTERFACE:${EXECUTORCH_ROOT}>
$<BUILD_INTERFACE:${EXECUTORCH_ROOT}/..>
$<BUILD_INTERFACE:${EXECUTORCH_SOURCE_INCLUDE_DIR}>
$<BUILD_INTERFACE:${EXECUTORCH_ROOT}/runtime/core/portable_type/c10>
$<INSTALL_INTERFACE:include>
)
Expand Down
4 changes: 3 additions & 1 deletion backends/apple/coreml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ if(APPLE)
target_include_directories(
coremldelegate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/delegate
)
target_include_directories(coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(
coremldelegate PRIVATE ${EXECUTORCH_SOURCE_INCLUDE_DIR}
)
target_include_directories(
coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/runtime/core/portable_type/c10
)
Expand Down
6 changes: 5 additions & 1 deletion backends/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ endif()
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
include(${EXECUTORCH_ROOT}/backends/arm/scripts/corstone_utils.cmake)
include(${EXECUTORCH_ROOT}/backends/arm/cmake/ArmEthosUSDK.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)

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

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

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
Expand Down Expand Up @@ -59,7 +63,7 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER)
)

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

Expand Down
8 changes: 6 additions & 2 deletions backends/cadence/fusion_g3/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

# ATen compliant ops that are needed to run this model.
set(_aten_ops__srcs
Expand Down Expand Up @@ -70,13 +73,14 @@ 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
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

target_include_directories(
aten_ops_cadence
PUBLIC
${ROOT_DIR}/..
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${_common_include_directories}
${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/generic/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ 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
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

target_include_directories(
Expand Down
10 changes: 7 additions & 3 deletions backends/cadence/generic/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

# ATen compliant ops that are needed to run this model.
set(_aten_ops__srcs
Expand Down Expand Up @@ -73,11 +76,12 @@ 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
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

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

Expand All @@ -86,7 +90,7 @@ file(GLOB custom_ops_srcs "*.cpp")
add_library(custom_ops ${custom_ops_srcs})

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

Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/hifi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ add_library(
)
# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

target_include_directories(
Expand Down
10 changes: 7 additions & 3 deletions backends/cadence/hifi/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

# ATen compliant ops that are needed to run this model.
set(_aten_ops__srcs
Expand Down Expand Up @@ -85,11 +88,12 @@ 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
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

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

Expand Down Expand Up @@ -155,7 +159,7 @@ add_library(
"op_quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out.cpp"
)
target_include_directories(
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
custom_ops PUBLIC ${EXECUTORCH_SOURCE_INCLUDE_DIR} ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/hifi/operators/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ add_compile_options(-Qunused-arguments -Wno-error)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

# Build googletest FOR the Xtensa target. find_package(GTest) would resolve the
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/vision/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ add_library(

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

target_include_directories(
Expand Down
11 changes: 8 additions & 3 deletions backends/cadence/vision/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)

if(NOT PYTHON_EXECUTABLE)
resolve_python_executable()
Expand Down Expand Up @@ -73,12 +76,14 @@ 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
${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

target_include_directories(
aten_ops_cadence
PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} ${_common_include_directories}
PUBLIC ${EXECUTORCH_SOURCE_INCLUDE_DIR} ${CMAKE_BINARY_DIR}
${_common_include_directories}
${CMAKE_CURRENT_SOURCE_DIR}/../third-party
)

Expand All @@ -97,7 +102,7 @@ add_library(
"op_im2row_out.cpp"
)
target_include_directories(
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
custom_ops PUBLIC ${EXECUTORCH_SOURCE_INCLUDE_DIR} ${CMAKE_BINARY_DIR}
${_common_include_directories}
)

Expand Down
5 changes: 4 additions & 1 deletion backends/cortex_m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ if(NOT EXECUTORCH_ROOT)
endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
include(FetchContent)

Expand Down Expand Up @@ -138,7 +141,7 @@ if(EXECUTORCH_BUILD_CORTEX_M)
)

target_include_directories(
cortex_m_kernels PRIVATE ${EXECUTORCH_ROOT}/..
cortex_m_kernels PRIVATE ${EXECUTORCH_SOURCE_INCLUDE_DIR}
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

Expand Down
5 changes: 4 additions & 1 deletion backends/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ endif()

# Use ExecuTorch's standard way to find PyTorch libraries for AOTI
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
executorch_get_build_include_dir(
"${EXECUTORCH_ROOT}" EXECUTORCH_SOURCE_INCLUDE_DIR
)
find_package_torch()

# Platform utilities (load_library, close_library, etc.)
Expand All @@ -203,7 +206,7 @@ add_library(cuda_platform STATIC ${_cuda_platform_sources})
target_include_directories(
cuda_platform
PUBLIC $<BUILD_INTERFACE:${EXECUTORCH_ROOT}> $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${EXECUTORCH_ROOT}/..>
$<BUILD_INTERFACE:${EXECUTORCH_SOURCE_INCLUDE_DIR}>
)

target_compile_options(
Expand Down
Loading
Loading