def step_total
bendtorch-core@0.1.0.0 · src/autograd/gradient.bend:44
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
44def step_total(-shape: Shape.Shape, +index: U32, contribution: Core.Dynamic, value: F32,
45 pair: Core.Tensor<shape> & Result<&2, &2, Core.Error, F32>) -> Step<shape>:
46 (total, result) = pair
47 match result:
48 case Fail{error}:
49 Stop{contribution, total, error}
50 case Done{+accumulated}:
51 step_write(shape, contribution, Core.write_flat(shape, total, index, F32.add(accumulated, value)))