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# PyTorch's input[..., start:stop:step, ...] with the slice at a signed axis
311# `dim`, wrapped among the rank, and signed start and stop: the unsigned
312# slice of the bounds. A rank-0 input has no axis, so every dim is refused.
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)

Uses (12)

Used by (2)