Signed.narrow: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed Lines 346-357 of bendtorch-core@0.1.0.0/src/tensor/signed.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&start_line=346&end_line=357 import Base import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice # PyTorch's input.narrow(dim, start, length) at a signed axis with a signed # start. PyTorch takes a start in -extent..extent: Last{k} with k below the # extent is extent - 1 - k, and one before -extent is OutOfRange. A First # start past the extent is refused by the unsigned narrow, which checks # start + length against the extent, with the same code. A length is a # U32, so PyTorch's negative lengths cannot be written. def narrow(input: Core.Dynamic, dim: Position, +start: Position, +length: U32) -> Core.Dynamic & Result<&2, &1, Slice.Error, Core.Dynamic>: Core.Packed{+shape, tensor} = input +axis = wrap(Shape.rank(shape), dim) +n = extent(Shape.dimensions(shape), axis) narrow_started(shape, tensor, axis, wrap(n, start), length, before(n, start)) Uses (12): 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=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/shape/core.bend&name=dimensions https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/shape/core.bend&name=rank https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/core.bend&name=Dynamic https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=Position https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=before https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=extent https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=narrow_started https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=wrap https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/slice.bend&name=Error