Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@grad_from_chainrules hygiene: cannot use custom types in method signature #224

Closed
manuelbb-upb opened this issue Apr 5, 2023 · 3 comments

Comments

@manuelbb-upb
Copy link

As noticed somewhere in FluxML/NNlib.jl#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) .

@avik-pal
Copy link

+1 for this. I had to solve this by manually defining the functions in https://github.com/LuxDL/LuxLib.jl/blob/65337c4b5cb8c49cca5472e9aad9e3d69d51e553/ext/LuxLibReverseDiffExt.jl#L50-L108

@mohamed82008
Copy link
Member

#232

@mohamed82008
Copy link
Member

fixed by #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants