Skip to content

Commit

Permalink
Add rule for push!(::IdSet)
Browse files Browse the repository at this point in the history
This is required on 1.11 because the underlying implementation has changed.
  • Loading branch information
ToucheSir committed Sep 22, 2024
1 parent f17ba75 commit fe6d2f0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ end
end
end

# IdSet (needed for nested AD with implicit params)

grad_mut(::IdSet) = IdSet()

function _pullback(cx::AContext, ::typeof(push!), s::IdSet, @nospecialize(x))
res = push!(s, x)
function idset_push!_pullback(_)
Δ = pop!(grad_mut(cx, s), x, nothing)
(nothing, Δ, nothing)
end
return res, idset_push!_pullback
end

# Dictionaries

grad_mut(d::AbstractDict) = Dict()
Expand Down

0 comments on commit fe6d2f0

Please sign in to comment.