law narrow_slices

bendtorch-core@0.1.0.0 · src/tensor/slice_LAWS.bend:242

import bendtorch-core@0.1.0.0/src/tensor/slice_LAWS.bend as SliceLAWS
import Base
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

242# PyTorch's narrow(dim, start, length) is the slice start:start + length
243# with step 1, once the axis is in range and start + length is at most the
244# extent; a start + length past the extent is refused with OutOfRange, an
245# axis past the rank as a slice refuses it.
246law narrow_slices:
247  for input: Core.Dynamic
248  for +dim: U32
249  for +start: U32
250  for +length: U32
251  for inside: {Nat.is_lt(U32.to_nat(dim), rank_of(input)) == True{} : Bool}
252  for fits: {Nat.is_le(Nat.add(U32.to_nat(start), U32.to_nat(length)), extent_of(input, dim)) == True{} : Bool}
253  {Slice.narrow(input, dim, start, length) == Slice.slice(input, dim, start, U32.add(start, length), 1) :
254    Core.Dynamic & Result<&2, &1, Slice.Error, Core.Dynamic>}

Uses (22)

Used by (0)

No other definition uses this definition.