Skip to content

Commit 151087a

Browse files
committed
Use copies instead of views of the kept columns of U, Vᴴ and V
Views with a vector index fall back to scalar indexing in mul! on GPU.
1 parent fc18c56 commit 151087a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/pullbacks/eigh.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function eigh_pullback!(
8888
# For k ≤ n / 2, applying these two blocks directly, in O(n² k), is faster than forming VᴴΔAV.
8989
ind′ = select_indices(axes(D, 1), ind)
9090
if 2 * length(ind′) <= n
91-
Vₖ = view(V, :, ind′)
91+
Vₖ = V[:, ind′]
9292
ΔA = mul!(ΔA, V * VᴴΔAVₖ, Vₖ', 1, 1)
9393
VᴴΔAVₖ[ind′, :] .= zero(eltype(VᴴΔAVₖ))
9494
ΔA = mul!(ΔA, Vₖ, VᴴΔAVₖ' * V', 1, 1)

‎src/pullbacks/svd.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ function svd_pullback!(
179179
# UᴴΔAV is nonzero only in its rows and columns ind′, which are UᴴΔAVₖ and UᴴΔAVʳ'. For k ≤ r / 2,
180180
# applying these two blocks directly, in O(m n k), is faster than forming UᴴΔAV.
181181
S′ = view(S, ind′)
182-
U′ = view(U, :, ind′)
183-
Vᴴ′ = view(Vᴴ, ind′, :) # this might be slightly confusion with adjoint
182+
U′ = U[:, ind′]
183+
Vᴴ′ = Vᴴ[ind′, :] # this might be slightly confusion with adjoint
184184
if 2 * length(ind′) <= r
185185
UᴴΔAVʳ[ind′, :] .= zero(eltype(UᴴΔAVʳ)) # these entries are part of the columns ind′
186186
ΔA = mul!(ΔA, U₁ * UᴴΔAVₖ, Vᴴ′, 1, 1)

0 commit comments

Comments
 (0)