Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update dpnp.diagonal()#1817

Merged
antonwolfy merged 15 commits intomasterIntelPython/dpnp:masterfrom
update_dpnp_diagonalIntelPython/dpnp:update_dpnp_diagonalCopy head branch name to clipboard
May 11, 2024
Merged

Update dpnp.diagonal()#1817
antonwolfy merged 15 commits intomasterIntelPython/dpnp:masterfrom
update_dpnp_diagonalIntelPython/dpnp:update_dpnp_diagonalCopy head branch name to clipboard

Conversation

@vlad-perevezentsev
Copy link
Contributor

@vlad-perevezentsev vlad-perevezentsev commented May 9, 2024

This PR suggests an updated implementation of dpnp.diagonal() including support for axis1, axis2 and negative offset parameters.

The new implementation shows performance improvements over the old implementation:

In [1]: import dpnp
 
In [2]: import numpy
 
In [3]: na = numpy.random.randint(-10**4, 10**4, size=(4096,4096))
 
In [4]: a = numpy.array(na,dtype='int32')
 
In [5]: a_dp = dpnp.array(a)
 
In [6]: res_dp = dpnp.diagonal(a_dp)
 
In [7]: %timeit -n 10 res_dp = dpnp.diagonal(a_dp)
16.9 ms ± 1.59 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
 
In [8]: %timeit -n 10 res_dp = dpnp.diagonal(a_dp,new=True)
17.8 µs ± 6.47 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
 
In [9]: a = numpy.array(na,dtype='float32')
 
In [10]: a_dp = dpnp.array(a)
 
In [11]: res_dp = dpnp.diagonal(a_dp)
 
In [12]: %timeit -n 10 res_dp = dpnp.diagonal(a_dp)
18 ms ± 1.21 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
 
In [13]: %timeit -n 10 res_dp = dpnp.diagonal(a_dp,new=True)
17.2 µs ± 4.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)


The backend implementation (dpnp_diagonal) is not removed due to the fact that dpnp_trace uses it

Additionally updating dpnp.diagonal() will allow to update dpnp.diag() function via reusing dpnp.diagonal()

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

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2024

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

dpnp/dpnp_iface_indexing.py Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
tests/test_sycl_queue.py Outdated Show resolved Hide resolved
tests/test_usm_type.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Outdated Show resolved Hide resolved
dpnp/dpnp_iface_indexing.py Show resolved Hide resolved
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.

@antonwolfy antonwolfy merged commit 05af730 into master May 11, 2024
@antonwolfy antonwolfy deleted the update_dpnp_diagonal branch May 11, 2024 12:29
github-actions bot added a commit that referenced this pull request May 11, 2024
* Update dpnp.diagonal to support offset and axes

* Update cupy tests for dpnp.diagonal()

* Update dpnp tests for dpnp.diagonal()

* Remove pytest.skip for a closed issue

* Extend test cases in test_diagonal_errors

* Update dpnp.ndarray.diagonal

* Update docstrings for dpnp.diagonal

* Address remarks

* Simplify getting axes_order

* Add cupy test_indexing.py to test scope

* Remove TODO from dpnp_det/dpnp_slogdet

* Improve test coverage

* Update the calculation of result parameters 05af730
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.