def slice
bendtorch-core@0.1.0.0 · src/tensor/signed.bend:310
import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed
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
310
311
312
313def slice(input: Core.Dynamic, dim: Position, start: Position, stop: Position, +step: U32) ->
314 Core.Dynamic & Result<&2, &1, Slice.Error, Core.Dynamic>:
315 Core.Packed{+shape, tensor} = input
316 +axis = wrap(Shape.rank(shape), dim)
317 +n = extent(Shape.dimensions(shape), axis)
318 Slice.slice(Core.Packed{shape, tensor}, axis, bound(n, start), bound(n, stop), step)