def projected_pair
bendtorch-core@0.1.0.0 · src/tensor/projection_PROOF.bend:12
import bendtorch-core@0.1.0.0/src/tensor/projection_PROOF.bend as ProjectionPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/flat.bend as Flat
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as ShapeLaws
import bendtorch-core@0.1.0.0/src/tensor/projection_LAWS.bend as Laws
12def projected_pair(+plan: Shape.BroadcastPlan,
13 +map: Shape.Index<Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan))>,
14 +index: Shape.FlatIndex<Shape.output_shape(plan)>) ->
15 {Some{(Shape.index_value(Shape.left_shape(plan), Flat.project_left_index(plan, map, index)),
16 Shape.index_value(Shape.right_shape(plan), Flat.project_right_index(plan, map, index)))} ==
17 Laws.offset_spec(plan, ShapeLaws.position(Shape.output_shape(plan), index)) : Maybe<&1, U32 & U32>}:
18 +left = Shape.extents(Shape.left_shape(plan))
19 +right = Shape.extents(Shape.right_shape(plan))
20 +output = Shape.extents(Shape.output_shape(plan))
21 +decoded = ShapeLaws.fin_of(Shape.numel(output), ShapeLaws.position(Shape.output_shape(plan), index))
22 +left_value = Shape.index_value(Shape.left_shape(plan), Flat.project_left_index(plan, map, index))
23 +right_value = Shape.index_value(Shape.right_shape(plan), Flat.project_right_index(plan, map, index))
24 %ShapeLaws.project_left_index_refines(plan, map, index) :
25 {Some{(left_value, right_value)} == Laws.pair_offsets(_, ShapeLaws.flatten_spec(right,
26 ShapeLaws.project_right_coordinate(left, right, output, Shape.alignment(plan), decoded))) : Maybe<&1, U32 & U32>}
27 %ShapeLaws.project_right_index_refines(plan, map, index) :
28 {Some{(left_value, right_value)} == Laws.pair_offsets(Some{left_value}, _) : Maybe<&1, U32 & U32>}
29 {==}