def map_decided

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

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

401def map_decided(+input: Shape.Shape, +axes: List<&2, U32>, +plan: Plan<input, axes>, +i: U32,
402  decision: Shape.BoolCase<U32.is_lt(i, Shape.count(output(input, axes, plan)))>) ->
403  Result<&2, &2, Error, Mapping<input, axes, plan, i>>:
404  match decision:
405    case Shape.BFalse{equal}:
406      Fail{ShapeError{Shape.FlatIndexOutOfBounds{}}}
407    case Shape.BTrue{equal}:
408      +words = reverse_words(unflatten_words(reverse_words(Shape.dimensions(output(input, axes, plan))), i))
409      map_output(input, axes, plan, i, FIndex{i, equal}, {==}, words, {==},
410        words_check(Shape.dimensions(output(input, axes, plan)), words))

Uses (18)

Used by (3)