Skip to content

Commit a137a94

Browse files
authored
1.8 compatibility: fix cholesky nopivot argument. (#390)
1 parent 6038634 commit a137a94

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
version: ['1.6', '^1.7.0-beta2', 'nightly']
17+
version: ['1.6', '^1.7', 'nightly']
1818
os: [ubuntu-latest, macOS-latest, windows-latest]
1919
arch: [x64]
2020
steps:

src/host/linalg.jl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,32 @@ end
101101

102102
Base.copy(D::Diagonal{T, <:AbstractGPUArray{T, N}}) where {T, N} = Diagonal(copy(D.diag))
103103

104-
# prevent scalar indexing
105-
function LinearAlgebra.cholesky!(D::Diagonal{T, <:AbstractGPUArray{T, N}},
106-
::Val{false} = Val(false); check::Bool = true
107-
) where {T, N}
108-
info = 0
109-
if mapreduce(x -> isreal(x) && isposdef(x), &, D.diag)
110-
D.diag .= sqrt.(D.diag)
111-
else
112-
info = findfirst(x -> !isreal(x) || !isposdef(x), collect(D.diag))
113-
check && throw(PosDefException(info))
104+
if VERSION <= v"1.8-"
105+
function LinearAlgebra.cholesky!(D::Diagonal{<:Any, <:AbstractGPUArray},
106+
::Val{false} = Val(false); check::Bool = true)
107+
info = 0
108+
if mapreduce(x -> isreal(x) && isposdef(x), &, D.diag)
109+
D.diag .= sqrt.(D.diag)
110+
else
111+
info = findfirst(x -> !isreal(x) || !isposdef(x), collect(D.diag))
112+
check && throw(PosDefException(info))
113+
end
114+
Cholesky(D, 'U', convert(LinearAlgebra.BlasInt, info))
115+
end
116+
else
117+
function LinearAlgebra.cholesky!(D::Diagonal{<:Any, <:AbstractGPUArray},
118+
::NoPivot = NoPivot(); check::Bool = true)
119+
info = 0
120+
if mapreduce(x -> isreal(x) && isposdef(x), &, D.diag)
121+
D.diag .= sqrt.(D.diag)
122+
else
123+
info = findfirst(x -> !isreal(x) || !isposdef(x), collect(D.diag))
124+
check && throw(PosDefException(info))
125+
end
126+
Cholesky(D, 'U', convert(LinearAlgebra.BlasInt, info))
114127
end
115-
Cholesky(D, 'U', convert(LinearAlgebra.BlasInt, info))
116128
end
117129

118-
119130
## matrix multiplication
120131

121132
function generic_matmatmul!(C::AbstractArray{R}, A::AbstractArray{T}, B::AbstractArray{S}, a::Number, b::Number) where {T,S,R}

0 commit comments

Comments
 (0)