def checked_indices_success
bendtorch-core@0.1.0.0 · src/tensor/elementwise_PROOF.bend:614
import bendtorch-core@0.1.0.0/src/tensor/elementwise_PROOF.bend as ElementwisePROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/shape/flat.bend as Flat
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
614def checked_indices_success(+plan: Shape.BroadcastPlan, +index: U32,
615 decision: Shape.BoolCase<Nat.is_lt(U32.to_nat(index), Shape.elements(Shape.output_shape(plan)))>,
616 -inside: {Nat.is_lt(U32.to_nat(index), Shape.elements(Shape.output_shape(plan))) == True{} : Bool}) ->
617 IndicesDone<plan, Elementwise.flat_input_indices(plan, Shape.flat_checked.finish(Shape.output_shape(plan), U32.to_nat(index), decision))>:
618 match decision:
619 case Shape.BFalse{equal}:
620 IndicesDone{0, 0,
621 Empty.absurd({Done{(0, 0)} == Fail{Core.ShapeError{Shape.FlatIndexOutOfBounds{}}} : Result<&2, &1, Core.Error, U32 & U32>},
622 Arith.clash(Equal.trans(Bool, False{}, Nat.is_lt(U32.to_nat(index), Shape.elements(Shape.output_shape(plan))), True{}, equal, inside))),
623 Empty.absurd({Nat.is_lt(0n, Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan)))) == True{} : Bool},
624 Arith.clash(Equal.trans(Bool, False{}, Nat.is_lt(U32.to_nat(index), Shape.elements(Shape.output_shape(plan))), True{}, equal, inside))),
625 Empty.absurd({Nat.is_lt(0n, Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan)))) == True{} : Bool},
626 Arith.clash(Equal.trans(Bool, False{}, Nat.is_lt(U32.to_nat(index), Shape.elements(Shape.output_shape(plan))), True{}, equal, inside)))}
627 case Shape.BTrue{equal}:
628 +flat = {Shape.FIndex{U32.to_nat(index), equal} : Shape.FlatIndex<Shape.output_shape(plan)>}
629 +left = Flat.project_left_index(plan, Shape.index_map(plan), flat)
630 +right = Flat.project_right_index(plan, Shape.index_map(plan), flat)
631 IndicesDone{Shape.index_value(Shape.left_shape(plan), left), Shape.index_value(Shape.right_shape(plan), right), {==},
632 flat_index_inside(Shape.left_shape(plan), left), flat_index_inside(Shape.right_shape(plan), right)}