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

Support F order for the tensor type. #8872

Merged
merged 2 commits into from
Mar 7, 2023
Merged

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Mar 6, 2023

  • Add F order support for tensor and view. Gradients for multi-class and multi-target are stored in F order when updating trees.
  • Use parameter pack for automatic type cast. (avoid excessive static cast for shape).

Extracted from #8616 .

auto idx = linalg::UnravelIndex(static_cast<std::size_t>(i),
{static_cast<std::size_t>(n_samples),
static_cast<std::size_t>(alpha.size()),
static_cast<std::size_t>(n_targets / alpha.size())});

// std::tie is not available for cuda kernel.
std::size_t sample_id = std::get<0>(idx);
std::size_t quantile_id = std::get<1>(idx);
std::size_t target_id = std::get<2>(idx);
auto [sample_id, quantile_id, target_id] =
linalg::UnravelIndex(i, n_samples, alpha.size(), n_targets / alpha.size());
Copy link
Member Author

@trivialfis trivialfis Mar 6, 2023

Choose a reason for hiding this comment

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

@hcho3 I think your work on c++-17 is really helpful.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome!

- Add F order support for tensor and view.
- Use parameter pack for automatic type cast. (avoid excessive static cast for shape).
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