Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Dictionaries = "0.4"
Enzyme = "0.13.216"
EnzymeTestUtils = "0.2.8"
FiniteDifferences = "0.12"
GPUArrays = "11.4.1"
GPUArrays = "11.4.1, 12.2"
LinearAlgebra = "1"
MatrixAlgebraKit = "0.6.14"
MemoizationKit = "0.1.2"
Expand Down
38 changes: 20 additions & 18 deletions src/factorizations/matrixalgebrakit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,26 @@ for (f!, bf!) in ((:svd_compact!, :batched_svd_compact!), (:svd_full!, :batched_
U, S, Vᴴ = F
driver = get(alg.kwargs, :driver, MAK.DefaultDriver())
cs = collect(union(map(blocksectors, (t, U, S, Vᴴ))...))
# no `return` inside `@timeit_debug`: it lowers to `try/finally`, and multiple
# returns through the `finally` make inference add a spurious `Nothing`
if !isempty(cs) && MAK.supports_ragged_batch(MAK.$f!, alg, driver, storagetype(t))
As = [block(t, c) for c in cs]
Fs = ([block(U, c) for c in cs], [block(S, c) for c in cs], [block(Vᴴ, c) for c in cs])
@timeit_debug GLOBAL_TIMER "batched: MatrixAlgebraKit" MAK.$bf!(As, Fs, alg)
return F
end
foreachblock(t, U, S, Vᴴ) do _, (tblock, Fblocks...)
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
Fblocks′ = $f!(tblock, Fblocks, alg)
# deal with the case where the output is not in-place
for (b′, b) in zip(Fblocks′, Fblocks)
b === b′ || copy!(b, b′)
else
foreachblock(t, U, S, Vᴴ) do _, (tblock, Fblocks...)
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
Fblocks′ = $f!(tblock, Fblocks, alg)
# deal with the case where the output is not in-place
for (b′, b) in zip(Fblocks′, Fblocks)
b === b′ || copy!(b, b′)
end
end
return nothing
end
return nothing
end
return F
end
return F
end
end

Expand Down Expand Up @@ -115,15 +117,15 @@ for (f!, bf!) in ((:svd_vals!, :batched_svd_vals!),)
if !isempty(cs) && MAK.supports_ragged_batch(MAK.$f!, alg, driver, storagetype(t))
As, Ss = last.(blocks(t)), last.(blocks(S))
@timeit_debug GLOBAL_TIMER "batched: MatrixAlgebraKit" MAK.$bf!(As, Ss, alg)
return S
end
foreachblock(t, S) do _, (tblock, Sblock)
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
Sblock′ = $f!(tblock, Sblock, alg)
# deal with the case where the output is not the same as the input
Sblock === Sblock′ || copy!(Sblock, Sblock′)
else
foreachblock(t, S) do _, (tblock, Sblock)
@timeit_debug GLOBAL_TIMER "dense: MatrixAlgebraKit" begin
Sblock′ = $f!(tblock, Sblock, alg)
# deal with the case where the output is not the same as the input
Sblock === Sblock′ || copy!(Sblock, Sblock′)
end
return nothing
end
return nothing
end
end
return S
Expand Down
Loading