Skip to content

Commit 6a009ba

Browse files
authored
Widen GPUArrays compat and fix inference issue (#625)
1 parent a00fb9a commit 6a009ba

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Dictionaries = "0.4"
5454
Enzyme = "0.13.216"
5555
EnzymeTestUtils = "0.2.8"
5656
FiniteDifferences = "0.12"
57-
GPUArrays = "11.4.1"
57+
GPUArrays = "11.4.1, 12.2"
5858
LinearAlgebra = "1"
5959
MatrixAlgebraKit = "0.6.14"
6060
MemoizationKit = "0.1.2"

‎src/factorizations/matrixalgebrakit.jl‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,26 @@ for (f!, bf!) in ((:svd_compact!, :batched_svd_compact!), (:svd_full!, :batched_
6363
U, S, Vᴴ = F
6464
driver = get(alg.kwargs, :driver, MAK.DefaultDriver())
6565
cs = collect(union(map(blocksectors, (t, U, S, Vᴴ))...))
66+
# no `return` inside `@timeit_debug`: it lowers to `try/finally`, and multiple
67+
# returns through the `finally` make inference add a spurious `Nothing`
6668
if !isempty(cs) && MAK.supports_ragged_batch(MAK.$f!, alg, driver, storagetype(t))
6769
As = [block(t, c) for c in cs]
6870
Fs = ([block(U, c) for c in cs], [block(S, c) for c in cs], [block(Vᴴ, c) for c in cs])
6971
@timeit_debug GLOBAL_TIMER "batched: MatrixAlgebraKit" MAK.$bf!(As, Fs, alg)
70-
return F
71-
end
72-
foreachblock(t, U, S, Vᴴ) do _, (tblock, Fblocks...)
73-
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
74-
Fblocks′ = $f!(tblock, Fblocks, alg)
75-
# deal with the case where the output is not in-place
76-
for (b′, b) in zip(Fblocks′, Fblocks)
77-
b === b′ || copy!(b, b′)
72+
else
73+
foreachblock(t, U, S, Vᴴ) do _, (tblock, Fblocks...)
74+
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
75+
Fblocks′ = $f!(tblock, Fblocks, alg)
76+
# deal with the case where the output is not in-place
77+
for (b′, b) in zip(Fblocks′, Fblocks)
78+
b === b′ || copy!(b, b′)
79+
end
7880
end
81+
return nothing
7982
end
80-
return nothing
8183
end
82-
return F
8384
end
85+
return F
8486
end
8587
end
8688

@@ -115,15 +117,15 @@ for (f!, bf!) in ((:svd_vals!, :batched_svd_vals!),)
115117
if !isempty(cs) && MAK.supports_ragged_batch(MAK.$f!, alg, driver, storagetype(t))
116118
As, Ss = last.(blocks(t)), last.(blocks(S))
117119
@timeit_debug GLOBAL_TIMER "batched: MatrixAlgebraKit" MAK.$bf!(As, Ss, alg)
118-
return S
119-
end
120-
foreachblock(t, S) do _, (tblock, Sblock)
121-
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
122-
Sblock′ = $f!(tblock, Sblock, alg)
123-
# deal with the case where the output is not the same as the input
124-
Sblock === Sblock′ || copy!(Sblock, Sblock′)
120+
else
121+
foreachblock(t, S) do _, (tblock, Sblock)
122+
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
123+
Sblock′ = $f!(tblock, Sblock, alg)
124+
# deal with the case where the output is not the same as the input
125+
Sblock === Sblock′ || copy!(Sblock, Sblock′)
126+
end
127+
return nothing
125128
end
126-
return nothing
127129
end
128130
end
129131
return S

0 commit comments

Comments
 (0)