law seed_selected_output

bendtorch-core@0.1.0.0 · src/autograd/backward_LAWS.bend:247

import bendtorch-core@0.1.0.0/src/autograd/backward_LAWS.bend as BackwardLAWS
import Base
import bendtorch-core@0.1.0.0/src/autograd/backward.bend as Backward

247# The seed is the selected output (C1). For any graph, the nodes newer than
248# the output get None, the output gets exactly 1.0, and the older nodes get
249# what the sweep sends from the output's VJP, whatever the newer nodes are.
250law seed_selected_output:
251  for +newer: List<&2, Backward.Node>
252  for +node: Backward.Node
253  for +rest: List<&2, Backward.Node>
254  {Backward.pass(List.append(&2, Backward.Node, newer, node <> rest),
255      List.length(&2, Backward.Node, List.append(&2, Backward.Node, newer, node <> rest)), List.length(&2, Backward.Node, rest)) ==
256    List.append(&2, Maybe<&2, F32>, Backward.nones(List.length(&2, Backward.Node, newer)),
257      Some{1.0} <> Backward.sweep(rest,
258        Backward.contribute(node, Some{1.0}, List.length(&2, Backward.Node, rest), Backward.nones(List.length(&2, Backward.Node, rest))),
259        List.length(&2, Backward.Node, rest))) : List<&2, Maybe<&2, F32>>}

Uses (14)

Used by (0)

No other definition uses this definition.