Developer Tools

PyTorch fixes Windows test failure with cpp wrapper int64 suffix bug

MSVC uses `LL` not `L` for int64 literals, breaking a CPU repro test.

Deep Dive

A 0d PyTorch pull request (#185145) by core contributor jansel addresses a Windows-specific regression in the C++ inductor wrapper. The issue: when compiling generated C++ code on Windows, MSVC requires `LL` suffix for int64 integer literals, while GCC/Clang on Linux use only `L`. The test `CPUReproTests.test_require_stride_order_non_owning` hardcoded the `L` suffix in its FileCheck expectation, causing the test to fail on Windows even when the generated code was semantically correct.

The fix refactors the int array literal generation into a dedicated helper function `cpp_int_array_str()`. This helper now returns the platform-appropriate suffix (`LL` on Windows, `L` elsewhere). The same helper is reused both in the existing `target_assert_size_stride_str` and in the failing repro test. This aligns with an earlier fix (#179846) that addressed MSVC const pointer emission for temporary arrays. The change is limited to the test expectation—no runtime behavior is altered.

Key Points
  • MSVC generates `{2LL, 3LL}` while GCC/Clang generate `{2L, 3L}` for int64 arrays.
  • New `cpp_int_array_str()` helper centralizes platform-specific literal formatting.
  • Fix enables `test_require_stride_order_non_owning` to pass on Windows CPUs.

Why It Matters

Ensures PyTorch's C++ induction works reliably on Windows, unblocking Windows ML developers.

📬 Get the top 10 AI stories daily