def plan_built_success

bendtorch-core@0.1.0.0 · src/tensor/permutation_mapping.bend:224

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
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as ShapeLaws
import bendtorch-core@0.1.0.0/src/tensor/axis_spec.bend as Axis

224def plan_built_success(+input: Shape.Shape, +axes: List<&2, U32>, +dimensions: List<&2, U32>,
225  +valid: {True{} == Layout.bijective(input, axes) : Bool},
226  +selected: {Some{dimensions} == Layout.reorder(Shape.dimensions(input), axes) : Maybe<&2, List<&2, U32>>},
227  built: Shape.ConstructResult<dimensions>,
228  complete: {ShapeLaws.built(dimensions, built) == Some{dimensions} : Maybe<&2, List<&2, U32>>},
229  +same: {dimensions == Axis.order(U32, Shape.dimensions(input), Shape.naturals(axes)) : List<&2, U32>}) ->
230  {Result.is_done(&2, &2, Layout.Error, Layout.Plan<input, axes>, Layout.plan_built(input, axes, dimensions, valid, selected, built)) == True{} : Bool}:
231  match built:
232    case Shape.SError{error}:
233      Empty.absurd({False{} == True{} : Bool},
234        Arith.clash(Equal.cong(Maybe<&2, List<&2, U32>>, Bool, metadata_present, None{}, Some{dimensions}, complete)))
235    case Shape.SBuilt{+output, +preserved}:
236      plan_counted_success(input, axes, output, valid,
237        Equal.trans(Maybe<&2, List<&2, U32>>, Some{Shape.dimensions(output)}, Some{dimensions}, Layout.reorder(Shape.dimensions(input), axes),
238          Equal.cong(List<&2, U32>, Maybe<&2, List<&2, U32>>, values => Some{values}, Shape.dimensions(output), dimensions, preserved), selected),
239        Shape.bool_case(Nat.is_eq(Shape.elements(input), Shape.elements(output))),
240        reordered_elements_same(input, axes, output, valid,
241          Equal.trans(List<&2, U32>, Shape.dimensions(output), dimensions, Axis.order(U32, Shape.dimensions(input), Shape.naturals(axes)), preserved, same)))

Uses (26)

Used by (1)