-
Couldn't load subscription status.
- Fork 700
Fix portable library build on Windows #13260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix portable library build on Windows #13260
Conversation
|
Stack from ghstack (oldest at bottom): |
🔗 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. |
|
@manuelcandales Any thoughts or preference on the approach used here? |
There was a problem hiding this 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!
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmao
|
I'm not sure, why ghstack merged this when re-ordering PRs. I'll re-open as a new PR. |
**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.
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.