-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Like #154
I am pretty sure there is a generic rrule for constructors.
Pretty sure I even wrote it down somewhere.
It is something like
function rrule(::Type{T}, args...) where T
constructor_pullback(dx::Tangent{T}) = (NoTangent(), canonicalize(dx)...)
# Special case for Zygote, which loses the primal type but also is always in canonical form anyway.
constructor_pullback(dx::Tangent{Any}) = (NoTangent(), dx...)
return T(args...), constructor_pullback
end
OTOH we only want to hit this for the default constructor (what Zygote basically has as __new__ I think)
Adding this more generally might break like all kinds of random constructors that we should be leaving alone?
idk
willtebbutt
Metadata
Metadata
Assignees
Labels
No labels