Tensor.sum_axis_bwd: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/tensor.bend as Tensor Lines 283-287 of bendtorch@1.3.0.0/tensor.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/tensor.bend&start_line=283&end_line=287 import Base # the gradient of sum_axis: dy (shape remove(s, k)) copied along axis k; dy comes back def sum_axis_bwd(+s: List<&2, Nat>, +k: Nat, dy: Tensor) -> TP: match dy: case Tensor{d}: tp_of(remove(s, k), s, gather_l(numel(s), 0, drop_map(s, k), Array.get(F32, d, imap(drop_map(s, k), 0)), new(numel(s)))) Uses (13): 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=drop_map https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=gather_l 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=new 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=remove https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/tensor.bend&name=tp_of