def narrow_checked

bendtorch-core@0.1.0.0 · src/tensor/slice.bend:416

import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice
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

416def narrow_checked(+shape: Shape.Shape, tensor: Core.Tensor<shape>, +dim: U32, +start: U32, +length: U32,
417  refused: Maybe<&2, Error>) -> Core.Dynamic & Result<&2, &1, Error, Core.Dynamic>:
418  match refused:
419    case Some{error}:
420      (Core.Packed{shape, tensor}, Fail{error})
421    case None{}:
422      narrow_ranged(shape, tensor, dim, start, length,
423        Nat.is_le(Nat.add(U32.to_nat(start), U32.to_nat(length)), extent_at(Shape.dimensions(shape), dim)))

Uses (15)

Used by (4)