TensorBackward.sum_dims: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward Lines 1412-1421 of bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&start_line=1412&end_line=1421 import Base import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed import bendtorch-core@0.1.0.0/src/autograd/sum_dims.bend as SumDims # Records PyTorch's a.sum(dim=axes, keepdim=keepdim), SumDims.sum_dims of a # copy of a's value: the kept shape when keepdim is True, else the dropped # one. The axes are PyTorch's signed ones: Last{0} is -1, a's last axis. An # empty axis list sums every axis. An axis outside -limit..limit-1, where # limit is max(rank, 1), so a rank-0 a takes -1 and 0, is refused with # AxisOutOfBounds (13), two axes that name one axis with DuplicateAxis (14), # an unknown id with UnknownNode; the tape comes back unchanged. def sum_dims(tape: Tape, +a: Nat, +axes: List<&2, Signed.Position>, keepdim: Bool) -> Tape & Result<&2, &2, Error, Nat>: Tape{entries} = tape dims_found(a, axes, keepdim, value_counted(a, counted(entries))) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool 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=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Error https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Tape https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=counted https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=dims_found https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=value_counted https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=Position