def linf_b3

bendtorch@1.3.0.0 · main.bend:707

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base
import bend-ml-tensor-array@0.1.18.0/main.bend as TA

707# the first layer of a model, whose input (the data) needs no gradient, as an input without requires_grad in PyTorch:
708# the backward pass computes dW and db only, skipping dX = dY·W (a third of a linear layer's work), and returns zeros
709# as dX. Use it only where nothing before the layer has parameters.
710def linf_b3(+n: Nat, +i: Nat, +o: Nat, w: TA.Mat<o, i>, b: TA.Mat<1n, o>, gb: TA.Mat<1n, o>, r: TA.MMulTN<o, n, i>) -> Bwd<Lin<i, o>, TA.Mat<n, i>>:
711  match r:
712    case TA.MMulTN{dy, x, gw}:
713      lin_b4(n, i, o, w, b, TA.Mat.zeros(n, i), gw, TA.Mat.col_sums_acc(n, o, dy, gb))

Uses (8)

Used by (3)