From 94c4f20779d0741c177e2a8a00c439380146c0de Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 14:44:48 -0700 Subject: [PATCH 01/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index b0455140f62..c4318e3daa5 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -6,8 +6,6 @@ on: branches: - main - release/* - paths: - - .github/workflows/build-presets.yml workflow_dispatch: concurrency: From 352c059e348c6b84cb33fb78b875ad387e44835f Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 15:57:45 -0700 Subject: [PATCH 02/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index c4318e3daa5..b771a274a68 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -127,6 +127,7 @@ jobs: python install_requirements.py cmake --preset ${{ matrix.preset }} + Write-Host "Build exit code: \$LASTEXITCODE" \$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1 cmake --build cmake-out -j \$numCores }" From d8f8b12c9cfc4e7c3a82979b66becdbabd66fa40 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 16:09:59 -0700 Subject: [PATCH 03/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index b771a274a68..058a1898f25 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -119,7 +119,7 @@ jobs: set -eux conda init powershell powershell -Command "& { - \$ErrorActionPreference = 'Stop' + $ErrorActionPreference = 'Stop' Set-PSDebug -Trace 1 conda create --yes --quiet -n et python=3.12 @@ -127,6 +127,7 @@ jobs: python install_requirements.py cmake --preset ${{ matrix.preset }} + Write-Host "Build exit code: \$LASTEXITCODE" \$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1 cmake --build cmake-out -j \$numCores From 8e8b78cd2dfce777e468e5af8e94e15d582c0ec1 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 16:22:18 -0700 Subject: [PATCH 04/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 058a1898f25..a0593120a5c 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -119,7 +119,7 @@ jobs: set -eux conda init powershell powershell -Command "& { - $ErrorActionPreference = 'Stop' + $$ErrorActionPreference = 'Stop' Set-PSDebug -Trace 1 conda create --yes --quiet -n et python=3.12 From 9cfd2b6caddf1e993be2a149a57ae94304241c86 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 16:33:10 -0700 Subject: [PATCH 05/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index a0593120a5c..fba797ed1d8 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -119,7 +119,8 @@ jobs: set -eux conda init powershell powershell -Command "& { - $$ErrorActionPreference = 'Stop' + \$ErrorActionPreference = 'Stop' + \$PSNativeCommandUseErrorActionPreference = \$true Set-PSDebug -Trace 1 conda create --yes --quiet -n et python=3.12 From 5b1330b09cf77591f2b91f5bb93af3236380f818 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 16:53:38 -0700 Subject: [PATCH 06/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index fba797ed1d8..160c07af15e 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -119,17 +119,24 @@ jobs: set -eux conda init powershell powershell -Command "& { + Set-PSDebug -Trace 1 \$ErrorActionPreference = 'Stop' \$PSNativeCommandUseErrorActionPreference = \$true - Set-PSDebug -Trace 1 conda create --yes --quiet -n et python=3.12 conda activate et python install_requirements.py cmake --preset ${{ matrix.preset }} + if (\$LASTEXITCODE -ne 0) { + Write-Host "CMake configuration was unsuccessful. Exit code: \$LASTEXITCODE." + exit \$LASTEXITCODE + } - Write-Host "Build exit code: \$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 + } }" From 378fcddb2c986a7d286d5a70e1537e12f71f04c7 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 8 Aug 2025 17:32:32 -0700 Subject: [PATCH 07/30] Update [ghstack-poisoned] --- devtools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/CMakeLists.txt b/devtools/CMakeLists.txt index 85492075b8c..077a6815288 100644 --- a/devtools/CMakeLists.txt +++ b/devtools/CMakeLists.txt @@ -7,7 +7,7 @@ # The include directory that will contain the generated schema headers. set(DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE ${CMAKE_BINARY_DIR}/devtools/include) set(DEVTOOLS_INCLUDE_DIR - $ + "$" ) add_subdirectory(etdump) From db12da0b78cac8898189528017e9c61376901e7f Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 10:54:13 -0700 Subject: [PATCH 08/30] Update [ghstack-poisoned] --- devtools/bundled_program/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/bundled_program/CMakeLists.txt b/devtools/bundled_program/CMakeLists.txt index 533a92a3e25..27a15206076 100644 --- a/devtools/bundled_program/CMakeLists.txt +++ b/devtools/bundled_program/CMakeLists.txt @@ -20,7 +20,7 @@ foreach(schema_file ${_schema_files}) ) endforeach() -file(MAKE_DIRECTORY ${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/bundled_program) +file(MAKE_DIRECTORY ${DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE}/executorch/devtools/bundled_program) add_custom_command( OUTPUT ${_schema_outputs} COMMAND From 4ee5cd0ec35b23d924f871fc27126af173588c6f Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 11:19:39 -0700 Subject: [PATCH 09/30] Update [ghstack-poisoned] --- devtools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/CMakeLists.txt b/devtools/CMakeLists.txt index 077a6815288..85492075b8c 100644 --- a/devtools/CMakeLists.txt +++ b/devtools/CMakeLists.txt @@ -7,7 +7,7 @@ # The include directory that will contain the generated schema headers. set(DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE ${CMAKE_BINARY_DIR}/devtools/include) set(DEVTOOLS_INCLUDE_DIR - "$" + $ ) add_subdirectory(etdump) From b79f2e1b55efdd3c60a610561d196b023708ae75 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 12:03:48 -0700 Subject: [PATCH 10/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 16 ++++------------ CMakePresets.json | 15 +++++++++++++++ tools/cmake/preset/windows.cmake | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 tools/cmake/preset/windows.cmake diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 160c07af15e..91c3bb09b23 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -6,6 +6,8 @@ on: branches: - main - release/* + paths: + - .github/workflows/build-presets.yml workflow_dispatch: concurrency: @@ -109,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - preset: [pybind] + preset: [pybind, windows] with: job-name: build ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} @@ -119,24 +121,14 @@ jobs: set -eux conda init powershell powershell -Command "& { - Set-PSDebug -Trace 1 \$ErrorActionPreference = 'Stop' - \$PSNativeCommandUseErrorActionPreference = \$true + Set-PSDebug -Trace 2 conda create --yes --quiet -n et python=3.12 conda activate et python install_requirements.py cmake --preset ${{ matrix.preset }} - 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/CMakePresets.json b/CMakePresets.json index 9a3e9290d43..cc293730292 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -120,6 +120,21 @@ ] } }, + { + "name": "windows", + "displayName": "Build ExecuTorch for Windows", + "inherits": ["common"], + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "Windows", + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/windows.cmake" + }, + "toolset": "ClangCL", + "condition": { + "lhs": "${hostSystemName}", + "type": "equals", + "rhs": "Windows" + } + }, { "name": "zephyr", "displayName": "Build ExecuTorch for Zephyr RTOS", diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake new file mode 100644 index 00000000000..e6be8aa6c3b --- /dev/null +++ b/tools/cmake/preset/windows.cmake @@ -0,0 +1,21 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + + +# keep sorted +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_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) From 0abe592f23ba2a811f2ee2a1ca36bf2187b26bbd Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 13:31:19 -0700 Subject: [PATCH 11/30] Update [ghstack-poisoned] --- backends/xnnpack/CMakeLists.txt | 2 +- tools/cmake/preset/windows.cmake | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 5e2bc3d3f9b..028709fcedc 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -59,7 +59,7 @@ foreach(fbs_file ${_xnnpack_schema__srcs}) ) endforeach() -if(WIN32 AND NOT CMAKE_CROSSCOMPILING) +if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") set(MV_COMMAND powershell -Command "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs}" diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index e6be8aa6c3b..45f8b724fae 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -12,10 +12,15 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) + +# These XNNPACK options don't currently build on Windows. +set_overridable_option(XNNPACK_ENABLE_AVX256SKX OFF) +set_overridable_option(XNNPACK_ENABLE_AVX256VNNI OFF) +set_overridable_option(XNNPACK_ENABLE_AVX256VNNIGFNI OFF) # 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) From 34a14700f068ce3d0e08d187efdd0b19f48dc2a1 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 15:29:24 -0700 Subject: [PATCH 12/30] Update [ghstack-poisoned] --- kernels/portable/cpu/op_amax.cpp | 3 ++- kernels/portable/cpu/op_amin.cpp | 3 ++- kernels/portable/cpu/op_argmax.cpp | 3 ++- kernels/portable/cpu/op_argmin.cpp | 3 ++- kernels/portable/cpu/op_max.cpp | 7 ++++--- kernels/portable/cpu/op_min.cpp | 7 ++++--- kernels/portable/cpu/op_relu.cpp | 5 ++++- kernels/portable/cpu/op_sign.cpp | 3 ++- kernels/portable/cpu/op_topk.cpp | 3 ++- kernels/portable/cpu/util/math_util.h | 20 +++++++++++++++++++- tools/cmake/preset/windows.cmake | 3 +-- 11 files changed, 44 insertions(+), 16 deletions(-) diff --git a/kernels/portable/cpu/op_amax.cpp b/kernels/portable/cpu/op_amax.cpp index 4ad409d4820..e055f5b9392 100644 --- a/kernels/portable/cpu/op_amax.cpp +++ b/kernels/portable/cpu/op_amax.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -51,7 +52,7 @@ Tensor& amax_out( for (const auto out_ix : c10::irange(begin, end)) { out_data[out_ix] = plan.execute( [](CTYPE v, CTYPE max_v) { - return std::isnan(v) || v > max_v ? v : max_v; + return utils::isnan_override(v) || v > max_v ? v : max_v; }, out_ix); } diff --git a/kernels/portable/cpu/op_amin.cpp b/kernels/portable/cpu/op_amin.cpp index 396cb6c016d..cc348dfefaa 100644 --- a/kernels/portable/cpu/op_amin.cpp +++ b/kernels/portable/cpu/op_amin.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,7 @@ Tensor& amin_out( for (const auto out_ix : c10::irange(begin, end)) { out_data[out_ix] = plan.execute( [](CTYPE v, CTYPE min_v) { - return std::isnan(v) || v < min_v ? v : min_v; + return utils::isnan_override(v) || v < min_v ? v : min_v; }, out_ix); } diff --git a/kernels/portable/cpu/op_argmax.cpp b/kernels/portable/cpu/op_argmax.cpp index 72881453d39..c7ee30cc0e8 100644 --- a/kernels/portable/cpu/op_argmax.cpp +++ b/kernels/portable/cpu/op_argmax.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -55,7 +56,7 @@ Tensor& argmax_out( // the below condition as written is equivalent to // !isnan(accval) && (isnan(v) || v > acc_val). See // argument in op_argmin.cpp. - if (!std::isnan(acc_val) && !(v <= acc_val)) { + if (!utils::isnan_override(acc_val) && !(v <= acc_val)) { acc_val = v; acc_ix = ix; } diff --git a/kernels/portable/cpu/op_argmin.cpp b/kernels/portable/cpu/op_argmin.cpp index 4e661c68694..d924cfeee39 100644 --- a/kernels/portable/cpu/op_argmin.cpp +++ b/kernels/portable/cpu/op_argmin.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,7 @@ Tensor& argmin_out( // - false, so the result is true. The result is trivially // - true for the above condition that uses isnan(v) as // - well. - if (!std::isnan(acc_val) && !(v >= acc_val)) { + if (!utils::isnan_override(acc_val) && !(v >= acc_val)) { acc_val = v; acc_ix = ix; } diff --git a/kernels/portable/cpu/op_max.cpp b/kernels/portable/cpu/op_max.cpp index 3f4a1d27c0e..cdea0834806 100644 --- a/kernels/portable/cpu/op_max.cpp +++ b/kernels/portable/cpu/op_max.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -88,8 +89,8 @@ std::tuple max_out( for (const auto out_ix : c10::irange(begin, end)) { std::tuple acc = reduce_over_dim( [](CTYPE v, long ix, CTYPE acc_val, long acc_ix) { - if (!std::isnan(acc_val) && - (std::isnan(v) || v > acc_val)) { + if (!utils::isnan_override(acc_val) && + (utils::isnan_override(v) || v > acc_val)) { acc_val = v; acc_ix = ix; } @@ -132,7 +133,7 @@ max_unary_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { data_out[0] = lower_bound(); for (const auto i : c10::irange(in.numel())) { CTYPE_OUT val = static_cast(data_in[i]); - if (std::isnan(val)) { + if (utils::isnan_override(val)) { data_out[0] = val; break; } diff --git a/kernels/portable/cpu/op_min.cpp b/kernels/portable/cpu/op_min.cpp index 8b70bcd40f5..d4d59d04128 100644 --- a/kernels/portable/cpu/op_min.cpp +++ b/kernels/portable/cpu/op_min.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -88,8 +89,8 @@ std::tuple min_out( for (const auto out_ix : c10::irange(begin, end)) { std::tuple acc = reduce_over_dim( [](CTYPE v, long ix, CTYPE acc_val, long acc_ix) { - if (!std::isnan(acc_val) && - (std::isnan(v) || v < acc_val)) { + if (!utils::isnan_override(acc_val) && + (utils::isnan_override(v) || v < acc_val)) { acc_val = v; acc_ix = ix; } @@ -132,7 +133,7 @@ min_unary_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { data_out[0] = upper_bound(); for (const auto i : c10::irange(in.numel())) { CTYPE_OUT val = static_cast(data_in[i]); - if (std::isnan(val)) { + if (utils::isnan_override(val)) { data_out[0] = val; break; } diff --git a/kernels/portable/cpu/op_relu.cpp b/kernels/portable/cpu/op_relu.cpp index 973542a2a77..4b848fa17e4 100644 --- a/kernels/portable/cpu/op_relu.cpp +++ b/kernels/portable/cpu/op_relu.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -45,7 +46,9 @@ Tensor& relu_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, "relu.out", CTYPE, [&]() { apply_unary_map_fn( [](const CTYPE val_in) { - return (std::isnan(val_in) || val_in >= CTYPE(0)) ? val_in : CTYPE(0); + return (utils::isnan_override(val_in) || val_in >= CTYPE(0)) + ? val_in + : CTYPE(0); }, in.const_data_ptr(), out.mutable_data_ptr(), diff --git a/kernels/portable/cpu/op_sign.cpp b/kernels/portable/cpu/op_sign.cpp index e6945094973..56d07133539 100644 --- a/kernels/portable/cpu/op_sign.cpp +++ b/kernels/portable/cpu/op_sign.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ Tensor& sign_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, "sign.out", CTYPE, [&] { apply_unary_map_fn( [](const CTYPE val_in) { - if (std::isnan(val_in)) { + if (utils::isnan_override(val_in)) { return val_in; } else { return static_cast((val_in > 0) - (val_in < 0)); diff --git a/kernels/portable/cpu/op_topk.cpp b/kernels/portable/cpu/op_topk.cpp index e35e67193bf..61b23c3eba4 100644 --- a/kernels/portable/cpu/op_topk.cpp +++ b/kernels/portable/cpu/op_topk.cpp @@ -10,6 +10,7 @@ #include #include +#include #include namespace torch { @@ -62,7 +63,7 @@ bool float_less_than(T x, T y) { if constexpr (std::is_integral_v) { return x < y; } - return (!std::isnan(x) && std::isnan(y)) || x < y; + return (!utils::isnan_override(x) && utils::isnan_override(y)) || x < y; } template > diff --git a/kernels/portable/cpu/util/math_util.h b/kernels/portable/cpu/util/math_util.h index 2c4828b9e6e..217b543636f 100644 --- a/kernels/portable/cpu/util/math_util.h +++ b/kernels/portable/cpu/util/math_util.h @@ -12,6 +12,9 @@ #include #endif +#include +#include + namespace torch { namespace executor { namespace native { @@ -29,7 +32,8 @@ template < typename std::enable_if::value, bool>::type = true> INT_T floor_divide(INT_T a, INT_T b) { const auto quot = a / b; - if (std::signbit(a) == std::signbit(b)) { + // MSVC does not like signbit on integral types. + if ((a < 0) == (b < 0)) { return quot; } const auto rem = a % b; @@ -52,6 +56,20 @@ FLOAT_T floor_divide(FLOAT_T a, FLOAT_T b) { return div; } +/** + * A wrapper around std::isnan that works with MSVC. When building with MSVC, + * std::isnan calls with integer inputs fail to compile due to ambiguous + * overload resolution. + */ +template +bool isnan_override(T a) { + if constexpr (!std::is_integral_v) { + return std::isnan(a); + } else { + return false; + } +} + /** * Override min/max so we can emulate PyTorch's behavior with NaN entries. */ diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index 45f8b724fae..e5aea2d84d8 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -6,6 +6,7 @@ # keep sorted +set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) 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) @@ -20,7 +21,5 @@ set_overridable_option(XNNPACK_ENABLE_AVX256VNNI OFF) set_overridable_option(XNNPACK_ENABLE_AVX256VNNIGFNI OFF) # 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) From 923f43eaba45234afdc02b9473c0f3036148830c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 16:30:51 -0700 Subject: [PATCH 13/30] Update [ghstack-poisoned] --- kernels/portable/cpu/op_amax.cpp | 2 +- kernels/portable/cpu/op_amin.cpp | 2 +- kernels/portable/cpu/op_argmax.cpp | 2 +- kernels/portable/cpu/op_argmin.cpp | 2 +- kernels/portable/cpu/op_max.cpp | 2 +- kernels/portable/cpu/op_min.cpp | 2 +- kernels/portable/cpu/op_topk.cpp | 1 + 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kernels/portable/cpu/op_amax.cpp b/kernels/portable/cpu/op_amax.cpp index e055f5b9392..9ae05bb1568 100644 --- a/kernels/portable/cpu/op_amax.cpp +++ b/kernels/portable/cpu/op_amax.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_amin.cpp b/kernels/portable/cpu/op_amin.cpp index cc348dfefaa..ca9d4fa8dce 100644 --- a/kernels/portable/cpu/op_amin.cpp +++ b/kernels/portable/cpu/op_amin.cpp @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_argmax.cpp b/kernels/portable/cpu/op_argmax.cpp index c7ee30cc0e8..7fdbaf540be 100644 --- a/kernels/portable/cpu/op_argmax.cpp +++ b/kernels/portable/cpu/op_argmax.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_argmin.cpp b/kernels/portable/cpu/op_argmin.cpp index d924cfeee39..37311f5b90f 100644 --- a/kernels/portable/cpu/op_argmin.cpp +++ b/kernels/portable/cpu/op_argmin.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_max.cpp b/kernels/portable/cpu/op_max.cpp index cdea0834806..05c1a23c5b1 100644 --- a/kernels/portable/cpu/op_max.cpp +++ b/kernels/portable/cpu/op_max.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_min.cpp b/kernels/portable/cpu/op_min.cpp index d4d59d04128..29405fb0182 100644 --- a/kernels/portable/cpu/op_min.cpp +++ b/kernels/portable/cpu/op_min.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_topk.cpp b/kernels/portable/cpu/op_topk.cpp index 61b23c3eba4..ce8b6ca1397 100644 --- a/kernels/portable/cpu/op_topk.cpp +++ b/kernels/portable/cpu/op_topk.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include From 1c0407ad7bdc918053a84f0182cc26b93b1ad93e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 16:57:47 -0700 Subject: [PATCH 14/30] Update [ghstack-poisoned] --- .../executorch/kernels/portable/op_registration_util.bzl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl index 73dfafdc65d..f447c48f1ab 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -246,6 +246,7 @@ ATEN_OPS = ( deps = [ "//executorch/runtime/core/exec_aten/util:scalar_type_util", "//executorch/runtime/core/exec_aten/util:tensor_util", + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -255,6 +256,7 @@ ATEN_OPS = ( "//executorch/runtime/core/exec_aten/util:scalar_type_util", "//executorch/runtime/core/exec_aten/util:tensor_util", "//executorch/kernels/portable/cpu/util:index_util", + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -278,12 +280,14 @@ ATEN_OPS = ( op_target( name = "op_argmax", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), op_target( name = "op_argmin", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -806,6 +810,7 @@ ATEN_OPS = ( op_target( name = "op_max", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -843,6 +848,7 @@ ATEN_OPS = ( op_target( name = "op_min", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -1236,6 +1242,9 @@ ATEN_OPS = ( ), op_target( name = "op_topk", + deps = [ + "//executorch/kernels/portable/cpu/util:math_util", + ] ), op_target( name = "op_transpose_copy", From 3b79e9d6506052a6a167ee193dff7c739312de3e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 17:32:48 -0700 Subject: [PATCH 15/30] Update [ghstack-poisoned] --- .../xplat/executorch/kernels/portable/op_registration_util.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl index f447c48f1ab..b8dbb2c67fe 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -1025,6 +1025,7 @@ ATEN_OPS = ( name = "op_relu", deps = [ "//executorch/kernels/portable/cpu/util:functional_util", + "//executorch/kernels/portable/cpu/util:math_util", ], ), op_target( From fc34c14e23c49c833e052e9ef6cfd37947f1f2d4 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 17:51:03 -0700 Subject: [PATCH 16/30] Update [ghstack-poisoned] --- .../xplat/executorch/kernels/portable/op_registration_util.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl index b8dbb2c67fe..4c63dd3420c 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -1136,6 +1136,7 @@ ATEN_OPS = ( name = "op_sign", deps = [ "//executorch/kernels/portable/cpu/util:functional_util", + "//executorch/kernels/portable/cpu/util:math_util", ], ), op_target( From fa3793a1dacf4b4b41a4bd091dfaa8a515714634 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 18:42:24 -0700 Subject: [PATCH 17/30] Update [ghstack-poisoned] --- kernels/portable/cpu/op_amax.cpp | 2 +- kernels/portable/cpu/op_amin.cpp | 2 +- kernels/portable/cpu/op_argmax.cpp | 2 +- kernels/portable/cpu/op_argmin.cpp | 2 +- kernels/portable/cpu/op_max.cpp | 2 +- kernels/portable/cpu/op_min.cpp | 2 +- kernels/portable/cpu/op_topk.cpp | 2 +- kernels/portable/cpu/util/math_util.h | 3 ++- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/kernels/portable/cpu/op_amax.cpp b/kernels/portable/cpu/op_amax.cpp index 9ae05bb1568..e055f5b9392 100644 --- a/kernels/portable/cpu/op_amax.cpp +++ b/kernels/portable/cpu/op_amax.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_amin.cpp b/kernels/portable/cpu/op_amin.cpp index ca9d4fa8dce..cc348dfefaa 100644 --- a/kernels/portable/cpu/op_amin.cpp +++ b/kernels/portable/cpu/op_amin.cpp @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_argmax.cpp b/kernels/portable/cpu/op_argmax.cpp index 7fdbaf540be..c7ee30cc0e8 100644 --- a/kernels/portable/cpu/op_argmax.cpp +++ b/kernels/portable/cpu/op_argmax.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_argmin.cpp b/kernels/portable/cpu/op_argmin.cpp index 37311f5b90f..d924cfeee39 100644 --- a/kernels/portable/cpu/op_argmin.cpp +++ b/kernels/portable/cpu/op_argmin.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_max.cpp b/kernels/portable/cpu/op_max.cpp index 05c1a23c5b1..cdea0834806 100644 --- a/kernels/portable/cpu/op_max.cpp +++ b/kernels/portable/cpu/op_max.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_min.cpp b/kernels/portable/cpu/op_min.cpp index 29405fb0182..d4d59d04128 100644 --- a/kernels/portable/cpu/op_min.cpp +++ b/kernels/portable/cpu/op_min.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/kernels/portable/cpu/op_topk.cpp b/kernels/portable/cpu/op_topk.cpp index ce8b6ca1397..e2143ce78d5 100644 --- a/kernels/portable/cpu/op_topk.cpp +++ b/kernels/portable/cpu/op_topk.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include namespace torch { diff --git a/kernels/portable/cpu/util/math_util.h b/kernels/portable/cpu/util/math_util.h index 217b543636f..a3a64997a5f 100644 --- a/kernels/portable/cpu/util/math_util.h +++ b/kernels/portable/cpu/util/math_util.h @@ -8,11 +8,12 @@ #pragma once +#include + #if defined(ET_USE_PYTORCH_HEADERS) && ET_USE_PYTORCH_HEADERS #include #endif -#include #include namespace torch { From 52b9ff1d73e936a3acf945df865db44741b3644f Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 9 Aug 2025 20:12:16 -0700 Subject: [PATCH 18/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 91c3bb09b23..8cb25c74691 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -6,8 +6,6 @@ on: branches: - main - release/* - paths: - - .github/workflows/build-presets.yml workflow_dispatch: concurrency: @@ -121,14 +119,24 @@ jobs: set -eux conda init powershell powershell -Command "& { + Set-PSDebug -Trace 1 \$ErrorActionPreference = 'Stop' - Set-PSDebug -Trace 2 + \$PSNativeCommandUseErrorActionPreference = \$true conda create --yes --quiet -n et python=3.12 conda activate et python install_requirements.py cmake --preset ${{ matrix.preset }} + 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 + } }" From cd7fd0eb667faa5e23276acad83672487e9b253d Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 19 Aug 2025 16:34:13 -0700 Subject: [PATCH 19/30] Update [ghstack-poisoned] --- devtools/bundled_program/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devtools/bundled_program/CMakeLists.txt b/devtools/bundled_program/CMakeLists.txt index 27a15206076..e9c5e0e424d 100644 --- a/devtools/bundled_program/CMakeLists.txt +++ b/devtools/bundled_program/CMakeLists.txt @@ -20,7 +20,10 @@ foreach(schema_file ${_schema_files}) ) endforeach() -file(MAKE_DIRECTORY ${DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE}/executorch/devtools/bundled_program) +file( + MAKE_DIRECTORY + ${DEVTOOLS_INCLUDE_DIR_NO_BUILD_INTERFACE}/executorch/devtools/bundled_program +) add_custom_command( OUTPUT ${_schema_outputs} COMMAND From 77d88d576bb6b8cb8fcab7886f016e7f00ca1e45 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 16:05:14 -0700 Subject: [PATCH 20/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 9140c91c99b..8cb25c74691 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -109,7 +109,7 @@ jobs: strategy: fail-fast: false matrix: - preset: [windows] # TODO (gjcomer) Re-enable pybind once functional + preset: [pybind, windows] with: job-name: build ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} From efe8513e972979444412b79c5bbb76982545e031 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 16:29:58 -0700 Subject: [PATCH 21/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 8cb25c74691..9fa8fb50151 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -127,7 +127,7 @@ jobs: conda activate et python install_requirements.py - cmake --preset ${{ matrix.preset }} + cmake --preset ${{ matrix.preset }} -T ClangCL if (\$LASTEXITCODE -ne 0) { Write-Host "CMake configuration was unsuccessful. Exit code: \$LASTEXITCODE." exit \$LASTEXITCODE From 35815db33bad76b6ef4960c7ff24a68f33c705bb Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 17:01:35 -0700 Subject: [PATCH 22/30] Update [ghstack-poisoned] --- tools/cmake/preset/pybind.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index e13fe026ef2..7321a29e72e 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -25,8 +25,10 @@ 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" ) From 35e6070122a2afea315c278b4d8652ac390a897c Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 17:02:28 -0700 Subject: [PATCH 23/30] Update [ghstack-poisoned] --- tools/cmake/preset/pybind.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index 7321a29e72e..c7ad94cd8be 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -21,7 +21,6 @@ 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) From c71aace7bee6718236a54897b9c85e223d938fb7 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 17:46:06 -0700 Subject: [PATCH 24/30] Update [ghstack-poisoned] --- tools/cmake/preset/pybind.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index c7ad94cd8be..3f63a056afa 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -31,7 +31,15 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 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() + + # 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) else() message( FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME for pybind: ${CMAKE_SYSTEM_NAME}" From 9fbb993e9179b0e3f9b8d8057184de912a1305d4 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 18:27:06 -0700 Subject: [PATCH 25/30] Update [ghstack-poisoned] --- extension/data_loader/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extension/data_loader/CMakeLists.txt b/extension/data_loader/CMakeLists.txt index 104cd23c977..1e7987a31eb 100644 --- a/extension/data_loader/CMakeLists.txt +++ b/extension/data_loader/CMakeLists.txt @@ -24,6 +24,9 @@ if(NOT ET_HAVE_SYS_MMAN_H AND NOT WIN32) "extension/data_loader/mmap_data_loader.cpp" ) endif() +if (WIN32) + list(APPEND _extension_data_loader__srcs "extension/data_loader/mman_windows.cpp") +endif() list(TRANSFORM _extension_data_loader__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library(extension_data_loader ${_extension_data_loader__srcs}) target_link_libraries(extension_data_loader executorch_core) From 395d2d43b3b2a8ca3db6c1dbd3b702c38847932d Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 19:04:36 -0700 Subject: [PATCH 26/30] Update [ghstack-poisoned] --- tools/cmake/preset/windows.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index c22a019e701..ebd2a6ff7a2 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -12,6 +12,8 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) # These XNNPACK options don't currently build on Windows. @@ -19,7 +21,3 @@ 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) - -# Below options are not yet buildable on Windows, but should be. -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) From a2de8919a8040f099ee5621472df269e646324b4 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 20:34:07 -0700 Subject: [PATCH 27/30] Update [ghstack-poisoned] --- extension/data_loader/CMakeLists.txt | 6 ++++-- tools/cmake/preset/pybind.cmake | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/extension/data_loader/CMakeLists.txt b/extension/data_loader/CMakeLists.txt index 1e7987a31eb..a5e7a0c4a81 100644 --- a/extension/data_loader/CMakeLists.txt +++ b/extension/data_loader/CMakeLists.txt @@ -24,8 +24,10 @@ if(NOT ET_HAVE_SYS_MMAN_H AND NOT WIN32) "extension/data_loader/mmap_data_loader.cpp" ) endif() -if (WIN32) - list(APPEND _extension_data_loader__srcs "extension/data_loader/mman_windows.cpp") +if(WIN32) + list(APPEND _extension_data_loader__srcs + "extension/data_loader/mman_windows.cpp" + ) endif() list(TRANSFORM _extension_data_loader__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library(extension_data_loader ${_extension_data_loader__srcs}) diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index 3f63a056afa..2a69a33cee4 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -31,8 +31,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32" ) - if (NOT CMAKE_GENERATOR_TOOLSET MATCHES "ClangCL") - message(FATAL_ERROR "ExecuTorch requires the ClangCL toolset on Windows. Please configure with -T ClangCL.") + if(NOT CMAKE_GENERATOR_TOOLSET MATCHES "ClangCL") + message( + FATAL_ERROR + "ExecuTorch requires the ClangCL toolset on Windows. Please configure with -T ClangCL." + ) endif() # These XNNPACK options don't currently build on Windows with Clang. From 8e1839a6c9ea230185e9078d10e48b6ed2a89969 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 25 Aug 2025 16:16:53 -0700 Subject: [PATCH 28/30] Update [ghstack-poisoned] --- install_requirements.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 15b4a23a879..3bd75cad6a3 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -112,8 +112,13 @@ def install_requirements(use_pytorch_nightly): LOCAL_REQUIREMENTS = [ "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. - "extension/llm/tokenizers", # TODO(larryliu0820): Setup a pypi package for this. - ] + ] + ( + [ + "extension/llm/tokenizers", # TODO(larryliu0820): Setup a pypi package for this. + ] + if sys.platform != "win32" + else [] + ) # TODO(gjcomer): Re-enable when buildable on Windows. # Install packages directly from local copy instead of pypi. # This is usually not recommended. From d2a3002b9699247706cf7c66d79efa832636a7dc Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 25 Aug 2025 16:58:47 -0700 Subject: [PATCH 29/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 37 +++++++++++++++++++++++++++++ CMakeLists.txt | 23 ++++++++++++------ 2 files changed, 53 insertions(+), 7 deletions(-) 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..33b13bed58b 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() From a8edd06712f1841b663b70a070b73623d677163a Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 25 Aug 2025 17:12:19 -0700 Subject: [PATCH 30/30] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 37 ----------------------------- CMakeLists.txt | 23 ++++++------------ 2 files changed, 7 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 9fa8fb50151..6f983ba58b6 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -103,40 +103,3 @@ 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 33b13bed58b..cbfea45b3c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -595,22 +595,13 @@ if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER) if(NOT WIN32) set(data_loader_exclude_pattern "*mman_windows.h") endif() - 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() + install( + DIRECTORY extension/data_loader/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/data_loader + FILES_MATCHING + PATTERN "*.h" + PATTERN ${data_loader_exclude_pattern} EXCLUDE + ) list(APPEND _executorch_extensions extension_data_loader) endif()