Skip to content

"Writing good rules" docs should comment on type constraints #155

Open
@nickrobinson251

Description

@nickrobinson251

the frule/rrule method signatures should have the same type constraints as the primal function (JuliaDiff/ChainRules.jl#175 (comment))

For example if your pacakge defines two methods for foo:

foo(::Number) = ...
foo(::AbstractMatrix) = ...

prefer defining

frule((_, ẋ), ::typeof(foo), x::Union{Number, AbstractMatrix}) = ...
rrule(::typeof(foo), x::Union{Number, AbstractMatrix}) = ...

to defining

frule((_, ẋ), ::typeof(foo), x) = ...
rrule(::typeof(foo), x) = ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions