def plan_built
bendtorch-core@0.1.0.0 · src/tensor/layout.bend:107
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
107def plan_built(+input: Shape.Shape, +axes: List<&2, U32>, -dimensions: List<&2, U32>,
108 valid: {True{} == bijective(input, axes) : Bool},
109 selected: {Some{dimensions} == reorder(Shape.dimensions(input), axes) : Maybe<&2, List<&2, U32>>},
110 built: Shape.ConstructResult<dimensions>) -> Result<&2, &2, Error, Plan<input, axes>>:
111 match built:
112 case Shape.SError{error}:
113 Fail{ShapeError{error}}
114 case Shape.SBuilt{+out, preserved}:
115 plan_counted(input, axes, out, valid,
116 Equal.trans(Maybe<&2, List<&2, U32>>, Some{Shape.dimensions(out)}, Some{dimensions},
117 reorder(Shape.dimensions(input), axes),
118 Equal.cong(List<&2, U32>, Maybe<&2, List<&2, U32>>, xs => Some{xs}, Shape.dimensions(out), dimensions, preserved), selected),
119 Shape.bool_case(Nat.is_eq(Shape.elements(input), Shape.elements(out))))