diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 6f983ba58b6..9fa8fb50151 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -103,3 +103,40 @@ jobs: ./install_requirements.sh > /dev/null cmake --preset ${{ matrix.preset }} cmake --build cmake-out -j$(( $(nproc) - 1 )) + + windows: + uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + strategy: + fail-fast: false + matrix: + preset: [pybind, windows] + with: + job-name: build + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + submodules: recursive + timeout: 90 + script: | + set -eux + conda init powershell + powershell -Command "& { + Set-PSDebug -Trace 1 + \$ErrorActionPreference = 'Stop' + \$PSNativeCommandUseErrorActionPreference = \$true + + conda create --yes --quiet -n et python=3.12 + conda activate et + + python install_requirements.py + cmake --preset ${{ matrix.preset }} -T ClangCL + if (\$LASTEXITCODE -ne 0) { + Write-Host "CMake configuration was unsuccessful. Exit code: \$LASTEXITCODE." + exit \$LASTEXITCODE + } + + \$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1 + cmake --build cmake-out -j \$numCores + if (\$LASTEXITCODE -ne 0) { + Write-Host "CMake build was unsuccessful. Exit code: \$LASTEXITCODE." + exit \$LASTEXITCODE + } + }" diff --git a/CMakeLists.txt b/CMakeLists.txt index cbfea45b3c1..fee287c5792 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -595,13 +595,22 @@ if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER) if(NOT WIN32) set(data_loader_exclude_pattern "*mman_windows.h") endif() - install( - DIRECTORY extension/data_loader/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/data_loader - FILES_MATCHING - PATTERN "*.h" - PATTERN ${data_loader_exclude_pattern} EXCLUDE - ) + if(DEFINED data_loader_exclude_pattern) + install( + DIRECTORY extension/data_loader/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/data_loader + FILES_MATCHING + PATTERN "*.h" + PATTERN ${data_loader_exclude_pattern} EXCLUDE + ) + else() + install( + DIRECTORY extension/data_loader/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/data_loader + FILES_MATCHING + PATTERN "*.h" + ) + endif() list(APPEND _executorch_extensions extension_data_loader) endif() diff --git a/backends/xnnpack/cmake/Dependencies.cmake b/backends/xnnpack/cmake/Dependencies.cmake index 8d5d0845430..a9b29cd1808 100644 --- a/backends/xnnpack/cmake/Dependencies.cmake +++ b/backends/xnnpack/cmake/Dependencies.cmake @@ -55,6 +55,14 @@ else() ) endif() +if(WIN32) + # These XNNPACK options don't currently build on Windows with Clang. + set_overridable_option(XNNPACK_ENABLE_AVX256SKX OFF) + set_overridable_option(XNNPACK_ENABLE_AVX256VNNI OFF) + set_overridable_option(XNNPACK_ENABLE_AVX256VNNIGFNI OFF) + set_overridable_option(XNNPACK_ENABLE_AVX512BF16 OFF) +endif() + set(XNNPACK_BUILD_ALL_MICROKERNELS OFF CACHE BOOL "" diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index e13fe026ef2..7665c726b20 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -21,16 +21,22 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_overridable_option(EXECUTORCH_BUILD_COREML ON) + set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set_overridable_option(EXECUTORCH_BUILD_COREML ON) + set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32" ) - # Windows or other OS-specific code here + if(NOT CMAKE_GENERATOR_TOOLSET MATCHES "ClangCL") + message( + FATAL_ERROR + "ExecuTorch requires the ClangCL toolset on Windows. Please configure with -T ClangCL." + ) + endif() else() message( FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for pybind: ${CMAKE_SYSTEM_NAME}" diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index fb44ed56494..5e20ff29c21 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -9,15 +9,9 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) +set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) - -# Below options are not yet buildable on Windows, but should be. -set(EXECUTORCH_BUILD_PORTABLE_OPS - OFF - CACHE BOOL "" -) -# set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) -# set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)