def combined

bendtorch-core@0.1.0.0 · src/autograd/gradient_LAWS.bend:16

import bendtorch-core@0.1.0.0/src/autograd/gradient_LAWS.bend as GradientLAWS
import Base
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

16# The value the specification assigns to one position after a contribution is
17# accumulated into a slot: an Unset slot takes the contribution's word as it
18# is, and a Held slot adds the contribution's word to its own with one F32 add,
19# the held total first.
20def combined(slot: Gradient.Slot, contribution: Core.Dynamic, +index: U32) -> Maybe<&2, F32>:
21  match slot:
22    case Gradient.Unset{}:
23      Core.checked_observe_dynamic(contribution, index)
24    case Gradient.Held{gradient}:
25      add_word(Core.checked_observe_dynamic(gradient, index), Core.checked_observe_dynamic(contribution, index))

Uses (7)

Used by (1)