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

Implement of dpnp.linalg.cholesky() #1638

Merged
merged 31 commits into from
Jan 20, 2024
Merged

Implement of dpnp.linalg.cholesky() #1638

merged 31 commits into from
Jan 20, 2024

Conversation

vlad-perevezentsev
Copy link
Collaborator

@vlad-perevezentsev vlad-perevezentsev commented Dec 7, 2023

This PR updates dpnp.linalg.cholesky() function to calculate the Cholesky factorization using oneapi::mkl::lapack::potrf and oneapi::mkl::lapack::potrf_batch
The implementation is written as a pybind11 extension above required LAPACK functions.

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

Copy link
Contributor

github-actions bot commented Dec 7, 2023

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

dpnp/backend/extensions/lapack/potrf.cpp Outdated Show resolved Hide resolved
dpnp/backend/extensions/lapack/potrf.cpp Outdated Show resolved Hide resolved
dpnp/linalg/dpnp_iface_linalg.py Outdated Show resolved Hide resolved
dpnp/linalg/dpnp_iface_linalg.py Outdated Show resolved Hide resolved
dpnp/linalg/dpnp_iface_linalg.py Outdated Show resolved Hide resolved
ht_lapack_ev.wait()
a_ht_copy_ev.wait()

a_h = dpnp.tril(a_h)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to create a copy here? can we control the required decomposition by upper_lower flag and to avoid the extra copying?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we need to get lower or upper triangular matrix with zeros above or below the main diagonal.
Since potrf and potrf_batch writes the result to the input array, we need to get rid of the input array data that has not changed.

dpnp/backend/extensions/lapack/potrf.cpp Outdated Show resolved Hide resolved
dpnp/backend/extensions/lapack/potrf.cpp Outdated Show resolved Hide resolved
dpnp/backend/extensions/lapack/potrf_batch.cpp Outdated Show resolved Hide resolved
dpnp/backend/extensions/lapack/potrf_batch.cpp Outdated 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.

LGTM! Thank you @vlad-perevezentsev

@antonwolfy antonwolfy merged commit 9b450f0 into master Jan 20, 2024
39 of 45 checks passed
@antonwolfy antonwolfy deleted the impl_cholesky branch January 20, 2024 09:53
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