src/tensor/contracts/pointwise_records.bend
bendtorch-core@0.1.0.0 · 21 lines · 1 definition
1import Base
2import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
3import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
4import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise.bend as Pointwise
5
6
7
8
9
10type PointwiseContract<-shape: Shape.Shape, -left: Shape.Shape, -right: Shape.Shape,
11 -cell: Nat -> F32, -left_word: U32 -> F32, -right_word: U32 -> F32,
12 -result: (Core.Dynamic & Core.Dynamic) & Result<&2, &1, Core.Error, Core.Dynamic>> is Type:
13 PointwiseContract{
14 successful: {Pointwise.succeeded(result) == True{} : Bool},
15 dimensions: {Pointwise.output_dimensions(result) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
16 value: @+index: U32 -> @inside: {Nat.is_lt(U32.to_nat(index), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
17 {Pointwise.output_point(result, index) == Some{cell(U32.to_nat(index))} : Maybe<&2, F32>},
18 left_kept: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(left))) == True{} : Bool} ->
19 {Pointwise.left_point(result, other) == Some{left_word(other)} : Maybe<&2, F32>},
20 right_kept: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(right))) == True{} : Bool} ->
21 {Pointwise.right_point(result, other) == Some{right_word(other)} : Maybe<&2, F32>}}