Skip to content

Commit 9469d79

Browse files
Jutholeburgel
authored andcommitted
more gpu view fixes
1 parent b1a5a74 commit 9469d79

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/pullbacks/eigh.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function check_and_prepare_eigh_cotangents(
2323
aVᴴΔV₀ = zero!(similar(V, (p, k)))
2424
end
2525

26-
D₀ = view(D, ind₀)
26+
D₀ = D[ind₀]
2727
gauge_part = (abs.(transpose(D₀) .- D) .< degeneracy_atol) .* aVᴴΔV₀
2828
Δgauge = maximum(abs, gauge_part; init = abs(zero(eltype(D))))
2929

‎src/pullbacks/svd.jl‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ function check_and_prepare_svd_cotangents(
1212
U₁ = view(U, :, 1:r)
1313
V₁ᴴ = view(Vᴴ, 1:r, :)
1414
S₁ = view(S, 1:r)
15-
indU = axes(U, 2)[ind]
16-
indV = axes(Vᴴ, 1)[ind]
17-
indS = axes(S, 1)[ind]
15+
16+
indU = select_indices(axes(U, 2), ind)
17+
indV = select_indices(axes(Vᴴ, 1), ind)
18+
indS = select_indices(axes(S, 1), ind)
1819
Δgauge = zero(eltype(S))
1920

2021
# Only the columns ind₀ ⊆ 1:r of UᴴΔAV are computed.
@@ -80,7 +81,7 @@ function check_and_prepare_svd_cotangents(
8081
aVᴴΔV₁₀ = zero!(similar(V₁ᴴ, (r, k)))
8182
end
8283

83-
S₀ = view(S, ind₀)
84+
S₀ = S[ind₀] # view fails broadcasting below on GPU
8485
hUᴴΔAV₁₀ = (aUᴴΔU₁₀ .+ aVᴴΔV₁₀) .* inv_safe.(transpose(S₀) .- S₁, degeneracy_atol) # hermitian part of UᴴΔAV, restricted to rows 1:r and columns ind₀
8586
aUᴴΔAV₁₀ = (aUᴴΔU₁₀ .- aVᴴΔV₁₀) .* inv_safe.(transpose(S₀) .+ S₁, degeneracy_atol) # antihermitian part of UᴴΔAV, restricted to rows 1:r and columns ind₀
8687

@@ -90,7 +91,7 @@ function check_and_prepare_svd_cotangents(
9091
if !iszerotangent(ΔSmat)
9192
ΔS = diagview(ΔSmat)
9293
length(indS) == length(ΔS) || throw(DimensionMismatch(lazy"length of selected S values ($(length(indS))) does not match length of ΔS ($(length(ΔS)))"))
93-
diagview(view(hUᴴΔAV₁₀, ind₀, :)) .+= real.(view(ΔS, J₁)) # the diagonal entries
94+
diagview(view(hUᴴΔAV₁₀, ind₀, :)) .+= real.(view(ΔS, J₁)) # diagonal entries
9495
Δgauge = max(Δgauge, maximum(abs, view(ΔS, J₂); init = zero(Δgauge)))
9596
end
9697

0 commit comments

Comments
 (0)