def lin_bwd
import bendtorch@1.3.0.0/main.bend as Bendtorchimport Base
import bend-ml-tensor-array@0.1.18.0/main.bend as TA
635# dX = dY·W, dW += dYᵀ·X, db += the column sums of dY; the two sums are added straight into the gradient (the
636# accumulating products of bend-ml-tensor-array 0.1.10.0), with the bits of computing them apart and adding them
637def lin_bwd(+n: Nat, +i: Nat, +o: Nat, +par: Nat, p: Lin<i, o>, x: TA.Mat<n, i>, dy: TA.Mat<n, o>, g: Lin<i, o>) -> Bwd<Lin<i, o>, TA.Mat<n, i>>:
638 match p:
639 case Lin{w, b}:
640 lin_b2(n, i, o, par, b, x, g, TA.Mat.matmul_precise(n, o, i, par, dy, w))