def read_pair_lift

bendtorch-core@0.1.0.0 · src/tensor/contracts/replayed.bend:102

import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
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

102def read_pair_lift(+shape: Shape.Shape, -kept: Storage.Storage, +found: F32,
103  pair: Core.Tensor<shape> & Result<&2, &2, Core.Error, F32>,
104  moved: {read_stored(shape, pair) == kept : Storage.Storage},
105  read: {Core.read_value(shape, pair) == Some{found} : Maybe<&2, F32>},
106  -P: Core.Tensor<shape> & Result<&2, &2, Core.Error, F32> -> Type,
107  h: @-fits: {Lifecycle.logical_length(kept) == Shape.logical_numel(Shape.dimensions(shape)) : Nat} ->
108    P((Core.TTensor{kept, fits}, Done{found}))) -> P(pair):
109  match pair:
110    case (Core.TTensor{storage, valid}, Fail{error}):
111      Empty.absurd(P((Core.TTensor{storage, valid}, Fail{error})),
112        Arith.clash(Equal.cong(Maybe<&2, F32>, Bool, word => Maybe.is_some(&2, F32, word), None{}, Some{found}, read)))
113    case (Core.TTensor{storage, valid}, Done{+word}):
114      read_shift(shape, storage, kept, word, found, Equal.sym(Storage.Storage, storage, kept, moved), some_value(found, word, Equal.sym(Maybe<&2, F32>, Some{word}, Some{found}, read)),
115        P, h)(valid)

Uses (23)

Used by (1)