Skip to content

Commit 583b948

Browse files
authored
Extend conversion of QRPackedQ object to CuArray (#1662)
1 parent e0710be commit 583b948

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/cusolver/linalg.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q)
114114
CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q)
115115
CuMatrix{T}(Q::QRPackedQ{S}) where {T,S} =
116116
CuMatrix{T}(lmul!(Q, CuMatrix{S}(I, size(Q, 1), min(size(Q.factors)...))))
117+
CuMatrix{T, B}(Q::QRPackedQ{S}) where {T, B, S} = CuMatrix{T}(Q)
117118
CuMatrix{T}(Q::QRCompactWYQ) where {T} = error("QRCompactWY format is not supported")
118119
# avoid the CPU array in the above mul!
119120
Matrix{T}(Q::QRPackedQ{S,<:CuArray,<:CuArray}) where {T,S} = Array(CuMatrix{T}(Q))
@@ -161,7 +162,8 @@ CuQRPackedQ(factors::AbstractMatrix{T}, τ::CuVector{T}) where {T} =
161162
# AbstractQ's `size` is the size of the full matrix,
162163
# while `Matrix(Q)` only gives the compact Q.
163164
# See JuliaLang/julia#26591 and JuliaGPU/CUDA.jl#969.
164-
CuMatrix{T}(Q::AbstractQ{S}) where {T,S} = convert(CuArray, Matrix{T}(Q))
165+
CuMatrix{T}(Q::AbstractQ{S}) where {T,S} = convert(CuArray{T}, Matrix(Q))
166+
CuMatrix{T, B}(Q::AbstractQ{S}) where {T, B, S} = CuMatrix{T}(Q)
165167
CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q)
166168
CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q)
167169
CuArray(Q::AbstractQ) = CuMatrix(Q)

test/cusolver/dense.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ k = 1
421421
@test Array(h_q) Array(q)
422422
@test collect(CuArray(h_q)) Array(q)
423423
@test Array(h_r) Array(r)
424+
@test CuArray(h_q) convert(typeof(d_A), h_q)
424425
A = rand(elty, n, m)
425426
d_A = CuArray(A)
426427
h_q, h_r = qr(d_A) # FixMe! Use iteration protocol when implemented

0 commit comments

Comments
 (0)