def map_input

bendtorch-core@0.1.0.0 · src/tensor/layout.bend:354

import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

354def map_input(+input: Shape.Shape, +axes: List<&2, U32>, +plan: Plan<input, axes>, +i: U32,
355  oi: FlatIndex<output(input, axes, plan)>, +oc: CheckedCoordinate<output(input, axes, plan)>,
356  requested: {index_value(output(input, axes, plan), oi) == i : U32},
357  decoded: {coordinate_values(output(input, axes, plan), oc) ==
358    reverse_words(unflatten_words(reverse_words(Shape.dimensions(output(input, axes, plan))), i)) : List<&2, U32>},
359  +words: List<&2, U32>,
360  inverse: {Some{words} == inverse_coordinates(Shape.dimensions(input), axes,
361    coordinate_values(output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>},
362  checked: Result<&2, &2, Shape.Error, WordsValid(Shape.dimensions(input), words)>) -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>:
363  match checked:
364    case Fail{error}:
365      Fail{ShapeError{error}}
366    case Done{valid}:
367      +ic = {CWord{words, valid} : CheckedCoordinate<input>}
368      map_roundtrip(input, axes, plan, i, oi, oc, ic, requested, decoded, inverse,
369        Shape.bool_case(maybe_same(reorder(words, axes), Some{coordinate_values(output(input, axes, plan), oc)})))

Uses (23)

Used by (2)