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

Add mean keyword to dpnp.std and dpnp.var #2271

Merged
merged 14 commits into from
Jan 27, 2025

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Jan 21, 2025

The PR proposes to add mean keyword argument to dpnp.std, dpnp.var, dpnp.nanstd, dpnp.nanvar functions and dpnp.ndarray.std, dpnp.ndarray.var methods.

The keyword was introduced by NumPy 2.0 and intended to improve the performance:

Often when the standard deviation is needed the mean is also needed; the same holds for the variance and the mean. With the current code the mean is then calculated twice, this can be prevented if the functions calculating the variance or the standard deviation can use a precalculated mean

This PR implements similar improvement in dpnp code.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

@antonwolfy antonwolfy self-assigned this Jan 21, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jan 21, 2025

Coverage Status

coverage: 71.297% (+0.02%) from 71.275%
when pulling e86a139 on add-mean-keyword-to-std-var
into d509d3f on master.

Copy link
Contributor

Array API standard conformance tests for dpnp=0.17.0dev4=py312he4f9c94_19 ran successfully.
Passed: 954
Failed: 0
Skipped: 46

@antonwolfy antonwolfy force-pushed the add-mean-keyword-to-std-var branch from eb07397 to 0f463e9 Compare January 22, 2025 11:24
Copy link
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2271/index.html

Disable pylint `duplicate-code` checker due to false-possitive issues
reported.
Copy link
Contributor

github-actions bot commented Jan 22, 2025

Array API standard conformance tests for dpnp=0.17.0dev5=py312he4f9c94_19 ran successfully.
Passed: 957
Failed: 0
Skipped: 43

@antonwolfy antonwolfy marked this pull request as ready for review January 22, 2025 13:00
Copy link
Collaborator

@vtavana vtavana left a comment

Choose a reason for hiding this comment

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

Thank you, @antonwolfy!

dpnp/dpnp_iface_statistics.py Outdated Show resolved Hide resolved
@antonwolfy antonwolfy merged commit b72f953 into master Jan 27, 2025
64 of 70 checks passed
@antonwolfy antonwolfy deleted the add-mean-keyword-to-std-var branch January 27, 2025 19:27
github-actions bot added a commit that referenced this pull request Jan 27, 2025
The PR proposes to add `mean` keyword argument to `dpnp.std`,
`dpnp.var`, `dpnp.nanstd`, `dpnp.nanvar` functions and
`dpnp.ndarray.std`, `dpnp.ndarray.var` methods.

The keyword was introduced by NumPy 2.0 and intended to improve the
performance:

> Often when the standard deviation is needed the mean is also needed;
the same holds for the variance and the mean. With the current code the
mean is then calculated twice, this can be prevented if the functions
calculating the variance or the standard deviation can use a
precalculated mean

This PR implements similar improvement in dpnp code. b72f953
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