Skip to content

Function to tell if you are being differentiated #547

Open
@mcabbott

Description

@mcabbott

Quite a few packages define a function to tell whether they are inside AD, as of https://github.com/FluxML/Flux.jl/pull/1863/files#r806287154 Flux has:

istraining() = false
# @adjoint istraining() = true, _ -> nothing
ChainRulesCore.rrule(::typeof(istraining)) = true, _ -> (NoTangent(),)

Maybe CRC should provide one?

It could be true/false. It could also be Val(true), or it could something more elaborate like:

order() = (fwd=0, rev=0, total=0)

What thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions