type FoldContract

bendtorch-core@0.1.0.0 · src/tensor/contracts/fold_records.bend:7

import bendtorch-core@0.1.0.0/src/tensor/contracts/fold_records.bend as FoldRecords
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/contracts/fold.bend as Fold

7# What a fold result promises, stated only through the result: it succeeds
8# with `total`, and the returned input still holds every word. `total` and
9# `word` are the specification; an instance fills them in.
10type FoldContract<-input: Shape.Shape, -total: F32, -word: U32 -> F32,
11  -result: Core.Dynamic & Result<&2, &1, Core.Error, F32>> is Type:
12  FoldContract{
13    value: {Fold.value(result) == Some{total} : Maybe<&2, F32>},
14    kept: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(input))) == True{} : Bool} ->
15      {Fold.input_point(result, other) == Some{word(other)} : Maybe<&2, F32>}}

Uses (15)

Used by (4)