Skip to content

Commit 2e4ec15

Browse files
committed
Copy the selected singular values and ΔS entries instead of viewing them
1 parent 3fe0045 commit 2e4ec15

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/pullbacks/svd.jl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ function check_and_prepare_svd_cotangents(
9090
if !iszerotangent(ΔSmat)
9191
ΔS = diagview(ΔSmat)
9292
length(indS) == length(ΔS) || throw(DimensionMismatch(lazy"length of selected S values ($(length(indS))) does not match length of ΔS ($(length(ΔS)))"))
93-
hUᴴΔAV₁₀[ind₀ .+ r .* (0:length(ind₀)-1)] .+= real.(view(ΔS, J₁)) # diagonal entries
94-
Δgauge = max(Δgauge, maximum(abs, view(ΔS, J₂); init = zero(Δgauge)))
93+
hUᴴΔAV₁₀[ind₀ .+ r .* (0:(length(ind₀) - 1))] .+= real.(ΔS[J₁]) # diagonal entries
94+
Δgauge = max(Δgauge, maximum(abs, ΔS[J₂]; init = zero(Δgauge)))
9595
end
9696

9797
Δgauge ≤ gauge_atol ||
@@ -148,7 +148,7 @@ function svd_pullback!(
148148
U₁ = view(U, :, 1:r)
149149
V₀ᴴ = Vᴴ[ind₀, :]
150150
V₁ᴴ = view(Vᴴ, 1:r, :)
151-
S₀ = view(S, ind₀)
151+
S₀ = S[ind₀]
152152

153153
# UᴴΔAV is nonzero only in its columns ind₀, which are hUᴴΔAV₁₀ + aUᴴΔAV₁₀, and its rows ind₀,
154154
# which are hUᴴΔAV₁₀' - aUᴴΔAV₁₀'. For k ≤ r / 2, applying these two blocks directly, in O(m n k),

0 commit comments

Comments
 (0)