@@ -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
8587end
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