def gradient

bendtorch-core@0.1.0.0 · src/autograd/gradient.bend:137

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

137# The gradient a slot holds; zeros of shape when it never received one.
138def gradient(+shape: Shape.Shape, slot: Slot) -> Result<&2, &1, Core.Error, Core.Dynamic>:
139  match slot:
140    case Unset{}:
141      Core.construct_values(shape, Core.new(shape, 0.0))
142    case Held{gradient}:
143      Done{gradient}

Uses (7)

Used by (2)