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
1.18.8: @grad_from_chainrules fails when a rule argument is named func ("function argument name not unique"), breaks ImplicitAD #334
Version: ReverseDiff 1.18.8 (also master e1bed86), Julia 1.12.5, Linux x86_64. 1.18.7 works.
Since 1.18.8 (#328), @grad_from_chainrules generates methods whose own self-argument is named func:
(func::ReverseDiff._selftype(f))(args...; kwargs...) where {...} = ReverseDiff.track(func, ...)
function ReverseDiff.track(func::ReverseDiff._selftype(f), args...; kwargs...) where {...}
If the rule's signature has an argument that is itself named func, the generated signature has two arguments
called func and lowering fails:
using ReverseDiff, ChainRulesCore
k(func, x) =func(sum(x))
ReverseDiff.@grad_from_chainrulesk(func, x::ReverseDiff.TrackedArray)
# ERROR: syntax: function argument name not unique: "func" around .../ReverseDiff/src/macros.jl:350
ReverseDiff
argument named f
argument named func
1.18.7
OK
OK
1.18.8
OK
syntax: function argument name not unique: "func"
This breaks precompilation of ImplicitAD.jl, whose src/external.jl:199 declares ReverseDiff.@grad_from_chainrules _provide_rule(func, x::ReverseDiff.TrackedArray, p, mode, jacobian, jvp, vjp),
and with it CCBlade.jl, FLOWVLM and FLOWUnsteady.
Possible fix: name the self-argument with a gensym, e.g. self = gensym(:func) and use $self in both
generated methods (lines 367 and 369 on master), so it cannot collide with a user-chosen name. The @grad
path (line 209) has the same pattern and probably the same issue for an argument named func; we have not
tested it.
We have not run ReverseDiff's test suite with a change; this is a report only.
Activity