def first_digit

bendtorch-core@0.1.0.0 · src/autograd/reduce.bend:51

import bendtorch-core@0.1.0.0/src/autograd/reduce.bend as Reduce
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

51# The first digit a row walks: 0 on a reduced axis (`Nat.div` by 0 is 0),
52# else the digit `target` names there.
53def first_digit(+rows: List<&2, Shape.Row>, +target: Nat) -> Nat:
54  match rows:
55    case Nil{}:
56      0n
57    case Shape.Row{stride, +left, right} <> rest:
58      Nat.div(target, left)

Uses (4)

Used by (21)