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] Implement unravel_index for row-major array. #723

Merged
merged 8 commits into from
Jun 29, 2022

Conversation

trivialfis
Copy link
Member

Revised version of #631 with thrust::tuple replaced by std::tuple and custom apply function replaced by std::apply.

Related: #629

The implementation is mostly copied from XGBoost https://github.com/dmlc/xgboost/blob/fdf533f2b9af9c068cddba50839574c6abb58dc3/include/xgboost/linalg.h#L523 .

In the tests, I have used both __host__ __device__ and __device__ lambdas to make sure std::tuple and std::apply are working correctly with CUDA kernel.

@trivialfis trivialfis added feature request New feature or request non-breaking Non-breaking change labels Jun 24, 2022
@trivialfis trivialfis requested a review from a team as a code owner June 24, 2022 01:46
@github-actions github-actions bot added the cpp label Jun 24, 2022
@trivialfis
Copy link
Member Author

rerun tests

cpp/include/raft/core/mdarray.hpp Show resolved Hide resolved
*/
template <typename LayoutPolicy, std::size_t... Exts>
MDSPAN_INLINE_FUNCTION auto unravel_index(size_t idx,
Copy link
Member

Choose a reason for hiding this comment

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

std::size_t idx as even extents are expressed as that type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't tested the updated mdspan and its new extent type yet.

Copy link
Member

Choose a reason for hiding this comment

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

Fair. We'll update it when we update mdspan

Copy link
Member

@divyegala divyegala Jun 27, 2022

Choose a reason for hiding this comment

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

Could this parameter possibly be optional with a default type/value? For those wishing to use the template param directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I will update the parameter type

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

Am I missing the updates?

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the parameter type of std::size_t idx into template Idx idx

Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @trivialfis for the change to use std::tuple instead of exposing thrust.

@cjnolet
Copy link
Member

cjnolet commented Jun 29, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 12146f2 into rapidsai:branch-22.08 Jun 29, 2022
@trivialfis trivialfis deleted the fea-unravel-index branch June 30, 2022 11:29
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants