Skip to content

implement dpnp.mean #1632

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

Merged
merged 3 commits into from
Nov 29, 2023
Merged

implement dpnp.mean #1632

merged 3 commits into from
Nov 29, 2023

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented Nov 27, 2023

In this PR, dpnp.mean is implemented using its dpctl counterpart.

  • 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?

@vtavana vtavana self-assigned this Nov 27, 2023
Copy link
Contributor

github-actions bot commented Nov 27, 2023

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

@vtavana vtavana marked this pull request as ready for review November 28, 2023 01:30
@vtavana vtavana requested a review from antonwolfy November 28, 2023 01:30
Copy link
Contributor

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

We need also to secure performance against the previous implementation of dpnp.mean on PVC and Iris Xe. Could you please check that here is no performance degradation comes with the new implementation?

@vtavana
Copy link
Collaborator Author

vtavana commented Nov 29, 2023

Performance on PVC (Intel(R) Data Center GPU Max 1550):
Timing is obtained using %timeit -r 7 -n 100 for three different cases:

  1. a = dpnp.arange(1024*32).reshape(1024,32)
Function Old implementation New Implementation
mean(a) 1.98 ms ± 128 µs 1.28 ms ± 44.4 µs
mean(a, axis=0) 2.39 ms ± 26.6 µs 1.52 ms ± 907 µs
mean(a, axis=1) 1.97 ms ± 269 µs 1.37 ms ± 494 µs
  1. a = dpnp.arange(1024*32).reshape(32,1024)
Function Old implementation New Implementation
mean(a) 1.89 ms ± 150 µs 1.3 ms ± 33 µs
mean(a, axis=0) 2.41 ms ± 48.3 µs 1.17 ms ± 34.1 µs
mean(a, axis=1) 2.33 ms ± 135 µs 1.18 ms ± 26.9 µs
  1. a = dpnp.arange(300*300).reshape(300,300)
Function Old implementation New Implementation
mean(a) 2.21 ms ± 78.3 µs 1.29 ms ± 58.5 µs
mean(a, axis=0) 2.4 ms ± 28.9 µs 1.15 ms ± 29.8 µs
mean(a, axis=1) 2.39 ms ± 30 µs 1.16 ms ± 34 µs

@vtavana
Copy link
Collaborator Author

vtavana commented Nov 29, 2023

Performance on Iris Xe (Intel(R) Graphics [0x46a8]):
Timing is obtained using %timeit -r 7 -n 100 for three different cases:

  1. a = dpnp.arange(1024*32).reshape(1024,32)
Function Old implementation New Implementation
mean(a) 2.13 ms ± 265 µs 621 µs ± 93 µs
mean(a, axis=0) 1.96 ms ± 127 µs 673 µs ± 102 µs
mean(a, axis=1) 1.97 ms ± 122 µs 674 µs ± 71.4 µs
  1. a = dpnp.arange(1024*32).reshape(32,1024)
Function Old implementation New Implementation
mean(a) 1.9 ms ± 101 µs 574 µs ± 87 µs
mean(a, axis=0) 1.99 ms ± 55.3 µs 737 µs ± 98.2 µs
mean(a, axis=1) 1.97 ms ± 105 µs 656 µs ± 85.1 µs
  1. a = dpnp.arange(300*300).reshape(300,300)
Function Old implementation New Implementation
mean(a) 1.92 ms ± 147 µs 622 µs ± 74.5 µs
mean(a, axis=0) 1.98 ms ± 113 µs 654 µs ± 103 µs
mean(a, axis=1) 1.96 ms ± 108 µs 698 µs ± 122 µs

@vtavana vtavana merged commit ad90f66 into master Nov 29, 2023
@vtavana vtavana deleted the mean branch November 29, 2023 20:40
github-actions bot added a commit to antonwolfy/dpnp that referenced this pull request Dec 4, 2023
* implement dpnp.mean

* address comments ad90f66
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.

2 participants