Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/rules/typeunstablerules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,8 @@ function rt_jl_getfield_aug(
dptr::T,
::Type{Val{symname}},
::Val{isconst},
dptrs::Vararg{T2,Nargs},
) where {NT,T,T2,Nargs,symname,isconst}
dptrs::Vararg{T,Nargs},
) where {NT,T,Nargs,symname,isconst}
res = if dptr isa Base.RefValue
Base.getfield(dptr[], symname)
else
Expand Down Expand Up @@ -1274,8 +1274,8 @@ function idx_jl_getfield_aug(
dptr::T,
::Type{Val{symname}},
::Val{isconst},
dptrs::Vararg{T2,Nargs},
) where {NT,T,T2,Nargs,symname,isconst}
dptrs::Vararg{T,Nargs},
) where {NT,T,Nargs,symname,isconst}
res = if dptr isa Base.RefValue
Base.getfield(dptr[], symname + 1)
else
Expand Down Expand Up @@ -1343,8 +1343,8 @@ function rt_jl_getfield_rev(
dret,
::Type{Val{symname}},
::Val{isconst},
dptrs::Vararg{T2,Nargs},
) where {T,T2,Nargs,symname,isconst}
dptrs::Vararg{T,Nargs},
) where {T,Nargs,symname,isconst}
cur = if dptr isa Base.RefValue
getfield(dptr[], symname)
else
Expand Down Expand Up @@ -1425,8 +1425,8 @@ function idx_jl_getfield_rev(
dret,
::Type{Val{symname}},
::Val{isconst},
dptrs::Vararg{T2,Nargs},
) where {T,T2,Nargs,symname,isconst}
dptrs::Vararg{T,Nargs},
) where {T,Nargs,symname,isconst}
cur = if dptr isa Base.RefValue
Base.getfield(dptr[], symname + 1)
else
Expand Down
22 changes: 22 additions & 0 deletions test/typeunstable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,26 @@ end
idx = Base.inferencebarrier(2)
res = Enzyme.autodiff(set_runtime_activity(Forward), getfield_unstable_fn, Duplicated([2.0, 3.0], [1.0, 0.0]), Const(idx))
@test res[1] ≈ 3.0
end

struct MiniProblem3280{U, P, K}
u0::U
tspan::Tuple{Float64, Float64}
p::P
kwargs::K
end

function loss_3280(p)
prob = MiniProblem3280([1.0], (0.0, 1.0), p, pairs((;)))
active_field = Enzyme.Compiler.idx_jl_getfield_aug(
Val(NamedTuple{(1,)}), prob, Val{2}, Val(false))
return sum(abs2, active_field)
end

@testset "idx_jl_getfield_aug calling convention (Issue 3280 reproducer)" begin
p = [0.5]
dp = zero(p)
Enzyme.autodiff(set_runtime_activity(Reverse), Enzyme.Const(loss_3280), Enzyme.Active,
Enzyme.Duplicated(p, dp))
@test dp ≈ [1.0]
end
Loading