Skip to content

Fix layout stride converting explicit clause#445

Merged
crtrott merged 4 commits intokokkos:stablefrom
nmm0:fix-layout-stride-converting-explicit-clause
Jan 28, 2026
Merged

Fix layout stride converting explicit clause#445
crtrott merged 4 commits intokokkos:stablefrom
nmm0:fix-layout-stride-converting-explicit-clause

Conversation

@nmm0
Copy link
Contributor

@nmm0 nmm0 commented Jan 19, 2026

We forgot to add the padded layouts to the layout_stride converting constructor, see https://eel.is/c++draft/mdspan.layout#stride.cons-9

This PR adds tests for all the strided layout conversions/constructions/assignments from other layouts

Copy link
Contributor

@mhoemmen mhoemmen left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes the layout_stride converting constructor to properly handle conversions from padded layouts (layout_left_padded and layout_right_padded). The fix ensures that conversions from padded layouts to layout_stride are implicit (when extents are convertible), consistent with how conversions from layout_left, layout_right, and layout_stride itself are handled.

Changes:

  • Added include for layout_padded_fwd.hpp to access padded layout type traits
  • Extended the MDSPAN_CONDITIONAL_EXPLICIT clause to include padded layout mappings in the list of layouts that should have implicit conversion
  • Added compile-time tests to verify constructibility, convertibility, and assignability for conversions between layout_stride and padded layouts

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
include/experimental/__p0009_bits/layout_stride.hpp Added include for padded layout traits and extended the converting constructor's explicit clause to handle padded layouts
compilation_tests/ctest_layout_convertible.cpp Added compile-time tests (guarded with C++17 check) to verify bidirectional conversion support between layout_stride and padded layouts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@crtrott crtrott merged commit 8b4eea2 into kokkos:stable Jan 28, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants