Skip to content

Commit 0a1ae38

Browse files
committed
Force memory transfer
1 parent 2c34bc4 commit 0a1ae38

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/implementations/svd.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ end
229229
function svd_trunc!(A, USVᴴ::Tuple{TU, TS, TVᴴ}, alg::TruncatedAlgorithm; compute_error::Bool = true) where {TU, TS, TVᴴ}
230230
ϵ = similar(USVᴴ[2], compute_error)
231231
(U, S, Vᴴ, ϵ) = svd_trunc!(A, (USVᴴ..., ϵ), alg)
232-
return compute_error ? (U, S, Vᴴ, ϵ[1]) : (U, S, Vᴴ, -one(eltype(ϵ)))
232+
return compute_error ? (U, S, Vᴴ, collect(ϵ)[1]) : (U, S, Vᴴ, -one(eltype(ϵ)))
233233
end
234234
function svd_trunc!(A, USVᴴ::Nothing, alg::TruncatedAlgorithm; compute_error::Bool = true)
235235
Tr = real(eltype(A))
236-
ϵ = compute_error ? zeros(Tr, 1) : zeros(Tr, 0)
236+
ϵ = zeros(Tr, compute_error)
237237
U, S, Vᴴ, ϵ = svd_trunc!(A, (USVᴴ, ϵ), alg)
238-
return compute_error ? (U, S, Vᴴ, ϵ[1]) : (U, S, Vᴴ, -one(Tr))
238+
return compute_error ? (U, S, Vᴴ, collect(ϵ)[1]) : (U, S, Vᴴ, -one(Tr))
239239
end
240240

241241
# Diagonal logic

test/cuda/svd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ end
140140
S₀ = svd_vals(hA)
141141
r = k
142142

143-
U1, S1, V1ᴴ, ϵ1 = @constinferred svd_trunc(A; alg, trunc = truncrank(r))
143+
U1, S1, V1ᴴ, ϵ1 = @constinferred svd_trunc(A; alg, trunc = truncrank(r), compute_error=false)
144144
@test length(S1.diag) == r
145145
@test opnorm(A - U1 * S1 * V1ᴴ) S₀[r + 1]
146146
@test norm(A - U1 * S1 * V1ᴴ) ϵ1
@@ -149,7 +149,7 @@ end
149149
s = 1 + sqrt(eps(real(T)))
150150
trunc2 = trunctol(; atol = s * S₀[r + 1])
151151

152-
U2, S2, V2ᴴ, ϵ2 = @constinferred svd_trunc(A; alg, trunc = trunctol(; atol = s * S₀[r + 1]))
152+
U2, S2, V2ᴴ, ϵ2 = @constinferred svd_trunc(A; alg, trunc = trunctol(; atol = s * S₀[r + 1]), compute_error=false)
153153
@test length(S2.diag) == r
154154
@test U1 U2
155155
@test parent(S1) parent(S2)

0 commit comments

Comments
 (0)