Skip to content

Commit 2bf6038

Browse files
authored
Instantiate broadcast for pullbacks (#266)
* Instantiate broadcast for SVD pullback This prevents an `axes` check from exploding further up the stack when PEPSKit tries to call this * Fix broadcast handling in eig pullback too * And eigh
1 parent ca49739 commit 2bf6038

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/pullbacks/eig.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function check_and_prepare_eig_cotangents(
3030
bc = Base.broadcasted(transpose(D), D, VᴴΔV₁) do d₁, d₂, v
3131
return abs(d₁ - d₂) < degeneracy_atol ? v : zero(v)
3232
end
33-
Δgauge = maximum(abs, bc; init = abs(zero(eltype(D))))
33+
Δgauge = maximum(abs, Base.Broadcast.instantiate(bc); init = abs(zero(eltype(D))))
3434

3535
Δgauge ≤ gauge_atol ||
3636
@warn "`eig` cotangents sensitive to gauge choice: (|Δgauge| = $Δgauge)"

‎src/pullbacks/eigh.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function check_and_prepare_eigh_cotangents(
3131
bc = Base.broadcasted(transpose(D), D, aVᴴΔV₁) do d₁, d₂, v
3232
return abs(d₁ - d₂) < degeneracy_atol ? v : zero(v)
3333
end
34-
Δgauge = maximum(abs, bc; init = abs(zero(eltype(D))))
34+
Δgauge = maximum(abs, Base.Broadcast.instantiate(bc); init = abs(zero(eltype(D))))
3535

3636
Δgauge ≤ gauge_atol ||
3737
@warn "`eigh` cotangents sensitive to gauge choice: (|Δgauge| = $Δgauge)"

‎src/pullbacks/svd.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function check_and_prepare_svd_cotangents(
8585
bc = Base.broadcasted(S₁', S₁, aUᴴΔU₁, aVᴴΔV₁) do s₁, s₂, u, v
8686
return abs(s₁ - s₂) < degeneracy_atol ? u + v : zero(u) + zero(v)
8787
end
88-
Δgauge = max(Δgauge, maximum(abs, bc))
88+
Δgauge = max(Δgauge, maximum(abs, Base.Broadcast.instantiate(bc)))
8989

9090
if !iszerotangent(ΔSmat)
9191
ΔS = diagview(ΔSmat)

0 commit comments

Comments
 (0)