Skip to content

Add suppport for different datatype in stats::mean#3056

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
lowener:fea-mean-dtype
Jul 1, 2026
Merged

Add suppport for different datatype in stats::mean#3056
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
lowener:fea-mean-dtype

Conversation

@lowener

@lowener lowener commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

This PR enables the support of two different data types for stats::mean. It will be used in NVIDIA/cuvs#2250
Add support for half in strided dataset. Enabled thanks to this PR: #1585

Closes #2625

Signed-off-by: Mickael Ide <mide@nvidia.com>
@lowener lowener requested a review from a team as a code owner June 23, 2026 20:25
@lowener lowener added enhancement New feature or request 3 - Ready for Review non-breaking Non-breaking change cpp labels Jun 23, 2026
@lowener lowener added the improvement Improvement / enhancement to an existing function label Jun 23, 2026
@aamijar aamijar requested a review from a team as a code owner June 27, 2026 04:10

@aamijar aamijar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @lowener, it looks good to me. From my understanding the main change is in the reduction function where we do the cast when reading the data, then do the add and divide ops.

So is the main purpose to calculate the mean in higher precision to avoid floating point errors?

@lowener

lowener commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Yes, the reduction function cast before doing the mean operation, so for example FP16 data can be accumulated in FP32.
Yes that's the main purpose, but for me it was just to allow more flexibility on input and output type, without using an intermediate buffer.

@achirkin achirkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, I've recently encountered a problem this PR will address too: calculating the average graph degree (which is uint32_t).

@achirkin

achirkin commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot rapids-bot Bot merged commit 2141422 into NVIDIA:main Jul 1, 2026
78 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review cpp enhancement New feature or request improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEA] Support fp16 input type in stats::mean()

4 participants