Closed
Description
Found in FluxML/Zygote.jl#1146 (comment) It will complain if the wrong function name is defined
julia> ChainRulesCore.@opt_out myrrule(::typeof(Base.:*), ::MyMatrix, ::AbstractMatrix{<:Real})
ERROR: LoadError: Unexpected opt-out target. Exprected frule or rrule, got: myrrule
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _no_rule_target_rewrite!(call_target::Symbol)
@ ChainRulesCore ~/JuliaEnvs/Zygote.jl/dev/ChainRulesCore/src/rule_definition_tools.jl:520
[3] _no_rule_target_rewrite!(expr::Expr)
@ ChainRulesCore ~/JuliaEnvs/Zygote.jl/dev/ChainRulesCore/src/rule_definition_tools.jl:505
[4] var"@opt_out"(__source__::LineNumberNode, __module__::Module, expr::Any)
@ ChainRulesCore ~/JuliaEnvs/Zygote.jl/dev/ChainRulesCore/src/rule_definition_tools.jl:493
in expression starting at REPL[14]:1
But not if rrule
(rather than ChainRulesCore.rrule
) is used, when it does the wrong thing:
julia> ChainRulesCore.@opt_out rrule(::typeof(Base.:*), ::MyMatrix, ::AbstractMatrix{<:Real})
rrule (generic function with 1 method)
julia> methods(rrule)
# 1 method for generic function "rrule":
[1] rrule(::typeof(*), ::MyMatrix, ::AbstractMatrix{<:Real}) in Main
Metadata
Metadata
Assignees
Labels
No labels