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

Matrix inversion for CuArray #116

Open
xukai92 opened this issue Oct 2, 2019 · 5 comments
Open

Matrix inversion for CuArray #116

xukai92 opened this issue Oct 2, 2019 · 5 comments
Labels
cuda array Stuff about CuArray. enhancement New feature or request

Comments

@xukai92
Copy link

xukai92 commented Oct 2, 2019

inv is not defined for CuArray

I attempted to use a wrap over CuArrays.CUBLAS.matinv_batched, i.e. Base.inv(x::CuArray{<:Real,2}) = CuArrays.CUBLAS.matinv_batched([x])[2][1]. But this only supports matrix smaller than 32x32.

Any idea how to support it formally?

@xukai92
Copy link
Author

xukai92 commented Oct 2, 2019

A related issue is :\ is not defined for CuArray but could be wrapped by several CUBALS functions:

const CuOrAdj = Union{CuArray, LinearAlgebra.Adjoint{T, CuArray{T, 2}}} where {T<:AbstractFloat}
function Base.:\(_A::AT1, _B::AT2) where {AT1<:CuOrAdj, AT2<:CuOrAdj}
    A, B = copy(_A), copy(_B)
    A, ipiv = CuArrays.CUSOLVER.getrf!(A)
    return CuArrays.CUSOLVER.getrs!('N', A, ipiv, B)
end

PS: this is related because some matrix inversion could be replaced by :\

@xukai92
Copy link
Author

xukai92 commented Oct 2, 2019

cc @mohamed82008 @MikeInnes

@MikeInnes
Copy link
Contributor

Perhaps we should start with a patch that adds \ to CuArrays, and then think about building inv on top?

@xukai92
Copy link
Author

xukai92 commented Oct 24, 2019

Perhaps we should start with a patch that adds \ to CuArrays, and then think about building inv on top?

On it.

@aterenin
Copy link
Contributor

aterenin commented Mar 18, 2020

I need inv for UpperTriangular types. I presume this is still something that's not been implemented? I can try to add and make a PR if so.

@maleadt maleadt transferred this issue from JuliaGPU/CuArrays.jl May 27, 2020
@maleadt maleadt added cuda array Stuff about CuArray. enhancement New feature or request labels May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda array Stuff about CuArray. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants