law signed_select_wraps

bendtorch-core@0.1.0.0 · src/tensor/signed_LAWS.bend:360

import bendtorch-core@0.1.0.0/src/tensor/signed_LAWS.bend as SignedLAWS
import Base
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed
import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice

360# A signed select is the unsigned select at the wrapped axis of the index
361# wrapped among that axis's extent: an index outside -extent..extent-1 stays
362# at or past the extent, which the unsigned select refuses.
363law signed_select_wraps:
364  for input: Core.Dynamic
365  for +dim: Signed.Position
366  for index: Signed.Position
367  {Signed.select(input, dim, index) ==
368    Slice.select(input, axis_of(input, dim), Signed.wrap(extent_of(input, axis_of(input, dim)), index)) :
369    Core.Dynamic & Result<&2, &1, Slice.Error, Core.Dynamic>}

Uses (10)

Used by (0)

No other definition uses this definition.