def built_lift

bendtorch-core@0.1.0.0 · src/tensor/reshape_contract.bend:57

import bendtorch-core@0.1.0.0/src/tensor/reshape_contract.bend as ReshapeContract
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as ShapeLaws
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/transforms.bend as Transforms

57def built_lift(+input: Shape.Shape, +target: Shape.Shape, -storage: Storage.Storage,
58  -valid: {Lifecycle.logical_length(storage) == Shape.logical_numel(Shape.dimensions(input)) : Nat},
59  built: Shape.ConstructResult<Shape.dimensions(target)>,
60  complete: {ShapeLaws.built(Shape.dimensions(target), built) == Some{Shape.dimensions(target)} : Maybe<&2, List<&2, U32>>},
61  +same: {Shape.logical_numel(Shape.dimensions(input)) == Shape.logical_numel(Shape.dimensions(target)) : Nat}, -P: Result<&2, &1, Transforms.Error, Core.Dynamic> -> Type,
62  h: @+output: Shape.Shape -> @preserved: {Shape.dimensions(output) == Shape.dimensions(target) : List<&2, U32>} ->
63    @-fits: {Lifecycle.logical_length(storage) == Shape.logical_numel(Shape.dimensions(output)) : Nat} -> P(Done{Core.Packed{output, Core.TTensor{storage, fits}}})) ->
64  P(Transforms.reshape_built(input, Core.TTensor{storage, valid}, Shape.dimensions(target), built)):
65  match built:
66    case Shape.SError{error}:
67      Empty.absurd(P(Transforms.reshape_built(input, Core.TTensor{storage, valid}, Shape.dimensions(target), Shape.SError{error})),
68        Arith.clash(Equal.cong(Maybe<&2, List<&2, U32>>, Bool, found => Maybe.is_some(&2, List<&2, U32>, found), None{}, Some{Shape.dimensions(target)}, complete)))
69    case Shape.SBuilt{+output, +preserved}:
70      decided_lift(input, output, storage, valid, Shape.bool_case(Nat.is_eq(Shape.elements(input), Shape.elements(output))),
71        elements_output(input, target, output, same, preserved), P, h(output, preserved))

Uses (26)

Used by (1)