Skip to content

Conversation

@GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Aug 9, 2025

Enable build of the portable operator library (and executor_runner, now that we have portable) on the Windows preset. There are a couple of patterns that weren't building on Windows. Both std::nan and std::signbit complain about ambiguous overload resolution when given an integer argument.

To solve the std::isnan issue, I introduced isnan_override in math_util.h, following the naming pattern from max_override / min_override / etc. in the same file. It adds a specialized branch for integers to avoid calling std::isnan. For std::signbit, I just locally specialized.

I also re-enabled optimized and quantized kernel libraries in the Windows preset, as they now build with this change.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 9, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13260

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

GregoryComer added a commit that referenced this pull request Aug 9, 2025
ghstack-source-id: e7bf6ba
ghstack-comment-id: 3172145648
Pull-Request: #13260
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 9, 2025
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 9, 2025
ghstack-source-id: 8bebedc
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 9, 2025
ghstack-source-id: 10bf3ad
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: 9d42116
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: 05a414a
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: ced680d
ghstack-comment-id: 3172145648
Pull-Request: #13260
@GregoryComer GregoryComer marked this pull request as ready for review August 10, 2025 02:11
@GregoryComer
Copy link
Member Author

@manuelcandales Any thoughts or preference on the approach used here?

[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: f13950b
ghstack-comment-id: 3172145648
Pull-Request: #13260
Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was skeptical, but Google (and Godbolt https://godbolt.org/z/Tq8Tr9aWz) confirms this is a well-documented problem that happens when using MSVC. Thanks!

[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 14, 2025
ghstack-source-id: 4a1af65
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 14, 2025
ghstack-source-id: 05495ea
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 15, 2025
ghstack-source-id: 09d4353
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 19, 2025
ghstack-source-id: 160cf98
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Aug 19, 2025
ghstack-source-id: 9c69a79
ghstack-comment-id: 3172145648
Pull-Request: #13260
[ghstack-poisoned]
[ghstack-poisoned]
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lmao

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Base automatically changed from gh/GregoryComer/117/head to gh/GregoryComer/141/head August 26, 2025 00:12
@GregoryComer GregoryComer merged commit 1326917 into gh/GregoryComer/141/head Aug 26, 2025
@GregoryComer GregoryComer deleted the gh/GregoryComer/118/head branch August 26, 2025 00:12
@GregoryComer
Copy link
Member Author

I'm not sure, why ghstack merged this when re-ordering PRs. I'll re-open as a new PR.

GregoryComer added a commit that referenced this pull request Aug 27, 2025
**Note: This is a cherry-pick / identical copy of the existing approved
PR (#13260). I inadvertently
broke the ghstack when attempting to re-order the stack, leading to the
old PR being merged by ghstack into the ghstack-created branch (not
main).**

Enable build of the portable operator library (and executor_runner, now
that we have portable) on the Windows preset. There are a couple of
patterns that weren't building on Windows. Both std::nan and
std::signbit complain about ambiguous overload resolution when given an
integer argument.

To solve the std::isnan issue, I introduced isnan_override in
math_util.h, following the naming pattern from max_override /
min_override / etc. in the same file. It adds a specialized branch for
integers to avoid calling std::isnan. For std::signbit, I just locally
specialized.

I also re-enabled optimized and quantized kernel libraries in the
Windows preset, as they now build with this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants