def mapping_roundtrip_success
bendtorch-core@0.1.0.0 · src/tensor/permutation_mapping.bend:636
import bendtorch-core@0.1.0.0/src/tensor/permutation_mapping.bend as PermutationMapping
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
636def mapping_roundtrip_success(+input: Shape.Shape, +axes: List<&2, U32>, +plan: Layout.Plan<input, axes>, +index: U32,
637 +oi: Layout.FlatIndex<Layout.output(input, axes, plan)>, +oc: Layout.CheckedCoordinate<Layout.output(input, axes, plan)>, +ic: Layout.CheckedCoordinate<input>,
638 +requested: {Layout.index_value(Layout.output(input, axes, plan), oi) == index : U32},
639 +decoded: {Layout.coordinate_values(Layout.output(input, axes, plan), oc) == Layout.reverse_words(Layout.unflatten_words(Layout.reverse_words(Shape.dimensions(Layout.output(input, axes, plan))), index)) : List<&2, U32>},
640 +inverse: {Some{Layout.coordinate_values(input, ic)} == Layout.inverse_coordinates(Shape.dimensions(input), axes, Layout.coordinate_values(Layout.output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>},
641 decision: Shape.BoolCase<Layout.maybe_same(Layout.reorder(Layout.coordinate_values(input, ic), axes), Some{Layout.coordinate_values(Layout.output(input, axes, plan), oc)})>,
642 roundtrip: {True{} == Layout.maybe_same(Layout.reorder(Layout.coordinate_values(input, ic), axes), Some{Layout.coordinate_values(Layout.output(input, axes, plan), oc)}) : Bool}) ->
643 {Result.is_done(&2, &2, Layout.Error, Layout.Mapping<input, axes, plan, index>,
644 Layout.map_roundtrip(input, axes, plan, index, oi, oc, ic, requested, decoded, inverse, decision)) == True{} : Bool}:
645 match decision:
646 case Shape.BFalse{equal}:
647 Empty.absurd({False{} == True{} : Bool}, Arith.clash(Equal.trans(Bool, False{},
648 Layout.maybe_same(Layout.reorder(Layout.coordinate_values(input, ic), axes), Some{Layout.coordinate_values(Layout.output(input, axes, plan), oc)}), True{}, equal,
649 Equal.sym(Bool, True{}, Layout.maybe_same(Layout.reorder(Layout.coordinate_values(input, ic), axes), Some{Layout.coordinate_values(Layout.output(input, axes, plan), oc)}), roundtrip))))
650 case Shape.BTrue{equal}:
651 mapping_flat_success(input, axes, plan, index, oi, oc, ic, requested, decoded, inverse, equal,
652 Layout.flatten_words(Shape.dimensions(input), Layout.coordinate_values(input, ic), 0), {==},
653 Shape.bool_case(U32.is_lt(Layout.flatten_words(Shape.dimensions(input), Layout.coordinate_values(input, ic), 0), Shape.count(input))),
654 checked_coordinate_flatten_bounded(input, ic))