Skip to content

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

@manuelbb-upb

Description

@manuelbb-upb

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) .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions