Skip to content

Conversation

JacobSzwejbka
Copy link
Contributor

@JacobSzwejbka JacobSzwejbka commented Oct 17, 2025

Summary

MSVC really doesn't like the constexpr variables that I've removed in this PR. It was complaining about them not actually being static at compile time. Searching around suggests that its the act of putting them in a variable that breaks it and if I just place the value directly in all the used locations it should be fine. I tried that and it works.

The other changes are fixing up some compiler flags, adding a missing include, fixing an interaction between lambdas the ternary operator and auto, and removing unneeded statement expressions

Test plan

current ci to verify no regression on linux/mac. Manual testing of msvc will add ci soon

Copy link

pytorch-bot bot commented Oct 17, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 1 Unrelated Failure

As of commit bc71d1c with merge base 173b046 (image):

NEW FAILURE - The following job has failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@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 Oct 17, 2025
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

_to_impl<CTYPE_IN, CTYPE_OUT>(self, out);
});
});
ET_SWITCH_COMPLEX_TYPES(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh lost the H on complexh

static_assert(
(std::is_same_v<Args, std::pair<const Tensor*, SupportedTensorDtypes>> &&
...));
constexpr auto kNumInputs = sizeof...(inputs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried a couple things to make msvc recognize kNumInputs here as being constant at compile time but it refused. Weirdly it does still recognize sizeof...(inputs) so I can just update the usage

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.

if this requires more than 1-2 more review rounds, you might be able to move faster by splitting out the uncontroversial strings changes; I could approve those right away.

ET_KERNEL_CHECK(
ctx, check_bmm_out_args(self, mat2, out), InvalidArgument, out);

constexpr auto name = "bmm.out";
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't suppose we are lucky enough that static constexpr auto name = "bmm.out"; would fix it?

Comment on lines +24 to +27
set(_common_compile_options
$<$<CXX_COMPILER_ID:MSVC>:/wd4996>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated-declarations>
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong preference here, just noting that the following is also valid:

if (MSVC)
  set(_common_compile_options /wd4996)
else()
  set(_common_compile_options -Wno-deprecated-declarations)
endif()

I like that it avoids the ugly $<$<NOT:$<X>>>, but I don't like that it duplicates the variable name. up to your sense of taste.

static_assert(
(std::is_same_v<Args, std::pair<const Tensor*, SupportedTensorDtypes>> &&
...));
constexpr auto kNumInputs = sizeof...(inputs);
Copy link
Contributor

Choose a reason for hiding this comment

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

the strings are understandable (I had to be pretty careful just to get clang to accept them IIRC), but this one is pretty disappointing and also seems to work on godbolt. have you tried generating a minimal example?

const auto cmp = largest ? elem_greater : elem_less;
if (use_partial_sort) {
std::partial_sort(queue, queue + k, queue + dim_size, cmp);
if (largest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the problem with this one? these don't seem to be constexpr variables at all. error message might be helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Piping lambdas into the ternary was having issues. It couldnt resolve that they had the same return type

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you should be able to fix that by explicitly using the appropriate function pointer type instead of auto

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.

2 participants