Tensor.sum_to: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/tensor.bend as Tensor Lines 256-260 of bendtorch@1.3.0.0/tensor.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/tensor.bend&start_line=256&end_line=260 import Base # g + (dz summed down to a's shape): the gradient of an operand that was broadcast from a to o; dz comes back def sum_to(+a: List<&2, Nat>, +o: List<&2, Nat>, dz: Tensor, g: Tensor) -> TP: match dz g: case Tensor{d} Tensor{e}: tp_of(o, a, scatter_l(numel(o), 0, bmap(a, o), Array.get(F32, d, 0), Array.get(F32, e, imap(bmap(a, o), 0)))) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=TP https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=Tensor https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=bmap https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=imap https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=numel https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=scatter_l https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=tp_of