Skip to content
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

[FEA] Helpers for identifying contiguous layouts. #1861

Merged
merged 10 commits into from
Oct 12, 2023

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Sep 28, 2023

  • Use strides to determine whether we can use a contiguous layout.

Useful for accepting inputs with stride information like numpy array or legate stores. The code is mostly copied and pasted from mdspan layout_left/right constructors. These constructors can optionally accept a stride layout if the underlying memory is contiguous, otherwise throw an exception. We change the exception into a boolean return value.

@trivialfis trivialfis requested a review from a team as a code owner September 28, 2023 02:21
@github-actions github-actions bot added the cpp label Sep 28, 2023
@trivialfis trivialfis changed the title Helpers for identifying contiguous layouts. [FEA] Helpers for identifying contiguous layouts. Sep 28, 2023
@trivialfis trivialfis added enhancement New feature or request feature request New feature or request non-breaking Non-breaking change 3 - Ready for Review and removed enhancement New feature or request labels Sep 28, 2023
@cjnolet cjnolet changed the base branch from branch-23.10 to branch-23.12 October 5, 2023 23:23
{
std::uint64_t stride = 1;
for (auto r = extents.rank(); r > 0; r--) {
if (stride != strides[r - 1]) { return false; }
Copy link
Member

Choose a reason for hiding this comment

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

In your test case, in the first iteration isn't stride = 1 and strides[r - 1] = 8 where r = 3? I don't understand how this doesn't exit in the first iteration itself

{
extents<std::int64_t, dynamic_extent, dynamic_extent, dynamic_extent> exts{10, 10, 10};
{
std::array<std::size_t, 3> strides{128, 32, 8};
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be {800, 80, 8}? I must be really misunderstanding something here

@trivialfis
Copy link
Member Author

@divyegala Apologies for the error, I got a bit confused now that I pick up the PR, how did I get the tests to pass (along with CI) ...

  • I have added an additional test to ensure the same unit is used between mdarray and the predicates.
  • Some changes in type consistency.

@cjnolet
Copy link
Member

cjnolet commented Oct 12, 2023

/merge

@rapids-bot rapids-bot bot merged commit 9624d31 into rapidsai:branch-23.12 Oct 12, 2023
59 checks passed
@trivialfis trivialfis deleted the mdspan-is-contiguous branch October 16, 2023 07:30
divyegala pushed a commit to divyegala/raft that referenced this pull request Oct 17, 2023
- Use strides to determine whether we can use a contiguous layout.

Useful for accepting inputs with stride information like numpy array or legate stores. The code is mostly copied and pasted from mdspan layout_left/right  constructors. These constructors can optionally accept a stride layout if the underlying memory is contiguous, otherwise throw an exception. We change the exception into a boolean return value.

Authors:
  - Jiaming Yuan (https://github.com/trivialfis)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Divye Gala (https://github.com/divyegala)

URL: rapidsai#1861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review cpp feature request New feature or request non-breaking Non-breaking change
Projects
Development

Successfully merging this pull request may close these issues.

3 participants