-
Notifications
You must be signed in to change notification settings - Fork 407
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 static extents assignment for LayoutLeft/LayoutRight assignment #5535
Conversation
Note the proper dimension check happens around line 281 or so. |
@@ -1128,9 +1128,8 @@ struct ViewOffset< | |||
KOKKOS_INLINE_FUNCTION constexpr ViewOffset( | |||
const ViewOffset<DimRHS, Kokkos::LayoutRight, void>& rhs) | |||
: m_dim(rhs.m_dim.N0, 0, 0, 0, 0, 0, 0, 0) { | |||
static_assert((DimRHS::rank == 0 && dimension_type::rank == 0) || | |||
(DimRHS::rank == 1 && dimension_type::rank == 1 && | |||
dimension_type::rank_dynamic == 1), |
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.
That line 1133 is the offending check.
Note this behavior was always intended (as the fact that it works for matching layouts attest too) and this is also how mdspan works. |
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 talked this through with @crtrott and agree with the logic
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.
The view assignable unit test could use some refactor (not requesting changes just saying)
Your changes should enable rank-0 view assignments as well isn't it? If I am not mistake please add tests for it.
Impl::TestAssignability<View<int[10], left, d_exec>, | ||
View<int*, right, d_exec>>::test(false, true, 10); | ||
Impl::TestAssignability<View<int*, left, d_exec>, | ||
View<int[5], right, d_exec>>::test(true, true, 5); |
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.
Wait why do you pass 5
? Isn't it something we only relaxed not so long ago? kokkos/kokkos-core-wiki#108
Please drop it here and below.
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.
yeah unnescessary here, gonna change that.
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.
Also added the rank-0 mixed layout case.
Impl::TestAssignability<View<int, left, d_exec>, | ||
View<int, right, d_exec>>::test(true, true); |
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.
No right -> left?
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 guess we could add them everywhere, but mostly this is about mismatch, not any specific layouts.
We always supported the following:
We also supported for always:
What apparently doesn't work is:
Turns out we do some extra checks for dynamic rank match, when accounting for LayoutLeft/LayoutRight convertibility of Rank 0 and Rank 1 Views.
That check is unnecessary, since it will get checked via the dimension assignability check already.
I.e. we hadn't properly orthogonalized the extents assignability from the Layout assignability for mixing LayoutLeft/LayoutRight.
This fixes this by getting rid of the erroneous condition.