-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<mdspan>
: Fix layout_stride::mapping<E>::is_exhaustive()
#5477
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
Merged
StephanTLavavej
merged 8 commits into
microsoft:main
from
JMazurkiewicz:mdspan/is_exhaustive
May 10, 2025
Merged
<mdspan>
: Fix layout_stride::mapping<E>::is_exhaustive()
#5477
StephanTLavavej
merged 8 commits into
microsoft:main
from
JMazurkiewicz:mdspan/is_exhaustive
May 10, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StephanTLavavej
approved these changes
May 9, 2025
Thanks! 😻 I pushed minor changes, please meow if I messed something up. |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
StephanTLavavej
added a commit
to StephanTLavavej/STL
that referenced
this pull request
May 9, 2025
Thanks for investigating this libcxx skip! 🛠️ 🕵️ 😻 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, our implementation of
layout_stride::mapping<E>::is_exhaustive()
gives incorrect result for some "unusual" extents. This PR attempts to fix it by adding a new way to compute an answer to the problem described in [mdspan.layout.stride.obs]/5.2 and extra return paths for simple cases:E::rank() == 1
,is_exhaustive()
returnstrue
if and only ifstride(0) == 1
.E::rank() == 2
,is_exhaustive()
returnstrue
if and only if one of the strides is equal to1
and the other stride is equal to extent corresponding to the previous stride.0
, thenis_exhaustive()
always returnsfalse
.0
or1
(these are "unusual" extents) this functions uses current method of comparingrequired_span_size()
tofwd-prod-of-extents(rank)
(extracted to separate function named_Is_exhaustive_common_case
)._Is_exhaustive_special_case
computes correct answer by finding a permutation of(stride, extent)
pairs described in [mdspan.layout.stride.obs]/5.2. If such permutation does not exist this function returnsfalse
.1
, mapping might be exhaustive, but this function (because of the way it is described) should returnfalse
. For example:libc++
test fails now due to bogus test - mapping tested here is clearly not exhaustive (at least one of the strides should be equal to1
). This also indicates that their implementation is incorrect.