Skip to content

Commit 7a91ff9

Browse files
committed
Fix #27 - mixup in lifiting of getfield
1 parent 085e051 commit 7a91ff9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/stage1/generated.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ lifted_getfield(x::ZeroTangent, s) = ZeroTangent()
380380
lifted_getfield(x::NoTangent, s) = NoTangent()
381381

382382
function lifted_getfield(x::Tangent, s)
383-
z = getfield(ChainRulesCore.backing(x), s)
383+
z = getfield(ChainRulesCore.backing(ChainRulesCore.canonicalize(x)), s)
384384
z
385385
end
386386

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,10 @@ end
182182
@test bwd(x->f_crit_edge(false, true, true, x))(1.0) == 12.0
183183
@test bwd(x->f_crit_edge(false, false, true, x))(1.0) == 4.0
184184

185+
# Issue #27 - Mixup in lifting of getfield
186+
let var"'" = bwd
187+
@test (x->x^5)''(1.0) == 20.
188+
@test (x->x^5)'''(1.0) == 60.
189+
end
185190

186191
include("pinn.jl")

0 commit comments

Comments
 (0)