As noticed somewhere in https://github.com/FluxML/NNlib.jl/issues/484, it appears that @grad_from_chainrule is not able to see custom types in method signatures. I looked through the issues here and hope I did not overlook it.
My guess is that method argument expressions should be escaped, here or in the parsing later on.
MWE
using ReverseDiff
struct myNumber val end
# define chain rules here ...
ReverseDiff.@grad_from_chainrules sin(x::myNumber)
This gives ERROR: UndefVarError: myNumber not defined.
If we look into @macroexpand ... we see stuff like sin(var"#54#x"::ReverseDiff.myNumber).
As noticed somewhere in https://github.com/FluxML/NNlib.jl/issues/484, it appears that
@grad_from_chainrule
is not able to see custom types in method signatures. I looked through the issues here and hope I did not overlook it. My guess is that method argument expressions should be escaped, here or in the parsing later on.MWE
This gives
ERROR: UndefVarError: myNumber not defined
. If we look into@macroexpand ...
we see stuff likesin(var"#54#x"::ReverseDiff.myNumber)
.