Skip to content

Proposal: Make pullback always take a single input #152

Closed
@oxinabox

Description

@oxinabox

Right now: (What i will call the Sometimes MultiOutput View)
we interpret a primal function returning a tuple as meaning it has multiple outputs,
and thus that the pullback should have multiple inputs.

The alternative view in this proposal (The Always Single Output View),
is that all julia functions only ever have a single output.
Sometimes that output is a tuple (or other iterables), in which case it is iterated on a,b=f(x) type assignement.
And thus all pullbacks should only ever accept a single input.

An implication of this is that if the primal returned a Tuple, the pushforward should return a Composite{Tuple} of derivatives, rather than a Tuple.


Sometime Multioutput (current)

Pros:

  • Nice to be able talk about multioutput functions having multinput pullbacks. Feels good.
  • Easy to write pullback for multiple output functions, as have them all directly

Cons:

Always Single output (proposed)

Pros

  • Nice to stay "Julia only has single output functions"
  • Tuples are not special vs other iterables.
  • Avoids splatting when the pullback used, which is probably good for performance (depending how the compiler is feeling)

Cons:

  • making pushforward return Composite{Tuple}(a,b,c) not (a, b, c) is a bit wordy.
  • dispatches become harded to write pullback((a,b,c)::Tuple{A, B, C}) this related to the The Extensibility Problem, for propagator closures #53 and if it even actually exists (if it doesn't this doens't matter).

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