def source
import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Sliceimport Base
203# The input index output cell `position` reads: position is (o * length + k)
204# * inner + r, and it reads (o * extent + start + k * step) * inner + r.
205def source(+plan: Plan, +position: Nat) -> Nat:
206 Plan{+outer, +extent, +inner, +start, +step, +length} = plan
207 +row = Nat.div(position, inner)
208 +o = Nat.div(row, length)
209 Nat.add(Nat.mul(Nat.add(Nat.mul(o, extent), Nat.add(start, Nat.mul(Nat.mod(row, length), step))), inner), Nat.mod(position, inner))