You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@grad_from_chainrules does not support where clauses #320
@grad_from_chainrules rejects signatures with a where clause:
using ReverseDiff, ChainRulesCore
f(x) =sum(x)
ChainRulesCore.rrule(::typeof(f), x) =f(x), Δ -> (NoTangent(), fill(Δ, size(x)))
ReverseDiff.@grad_from_chainrulesf(x::ReverseDiff.TrackedArray{T}) where {T <:AbstractFloat}
ERROR: LoadError: `@grad_from_chainrules` has to be applied to a function signature
Expected: the rule is imported for TrackedArray{<:AbstractFloat}, as with @grad, which accepts where clauses (covered by the f6/f7 tests in test/MacrosTests.jl). Without them you can't import a rule only for tracked arrays of a given element type, or tie the types of several arguments together (e.g. x::TrackedArray{T}, y::AbstractArray{T}).
Cause: the macro only accepts an Expr(:call, ...). A where clause wraps the call in Expr(:where, ...), and the generated method definitions don't carry whereparams through either.
ReverseDiff master (b796032, v1.18.4), Julia 1.13.1.
Activity