~/bend-docscommunity

src/autograd/gradient.bend checks

raw source on the hub · import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

5 imports
import Base
import ../shape/core.bend as Shape
import ../storage/main.bend as Storage
import ../tensor/core.bend as Core
import ../tensor/layout.bend as Layout

Types

type Error source · line 16 · raw

Data

type Slot source · line 20 · raw

Type

type Outcome source · line 24 · raw

Type

type State source · line 28 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> Type

type Step source · line 31 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> Type

Definitions

def step_write source · line 35 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @pair:Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Tensor<shape>, Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, Unit>) -> Step<shape>

def step_total source · line 44 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+index:U32 -> @contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @value:F32 -> @pair:Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Tensor<shape>, Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, F32>) -> Step<shape>

def step_contribution source · line 53 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+index:U32 -> @total:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Tensor<shape> -> @pair:Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, F32>) -> Step<shape>

def step source · line 62 · raw

@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+index:U32 -> @state:State<shape> -> Step<shape>

def continue_step source · line 66 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @rec:(@_:State<shape> -> Outcome) -> @result:Step<shape> -> Outcome

def conversion_error source · line 73 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @state:State<shape> -> Outcome

def decided source · line 77 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+cursor:Nat -> @+index:U32 -> @state:State<shape> -> @rec:(@_:State<shape> -> Outcome) -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<Nat.is_eq(U32.to_nat(index), cursor)> -> Outcome

def loop source · line 85 · raw

@fuel:Nat -> @+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+cursor:Nat -> @state:State<shape> -> Outcome

def held_checked source · line 95 · raw

@contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @+total_shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @total:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Tensor<total_shape> -> @same:Bool -> Outcome

def held source · line 102 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @gradient:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> Outcome

def agreed source · line 106 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @slot:Slot -> @contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> Outcome

def checked source · line 113 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @slot:Slot -> @+contribution_shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @tensor:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Tensor<contribution_shape> -> @same:Bool -> Outcome

def accumulate source · line 120 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @slot:Slot -> @contribution:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> Outcome

def grad source · line 126 · raw

@slot:Slot -> Maybe<&1, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>

The gradient a slot holds, or None when it never received one or was reset.

def reset source · line 134 · raw

@slot:Slot -> Slot

Drops a held gradient: the next contribution moves in unchanged.

def gradient source · line 138 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @slot:Slot -> Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>

The gradient a slot holds; zeros of shape when it never received one.

def error_code source · line 145 · raw

@error:Error -> U32