src/tensor/clone_metadata_records.bend
bendtorch-core@0.1.0.0 · 41 lines · 3 definitions
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/observation.bend as Observation
5
6type CloneContract<-shape: Shape.Shape, -fill: F32> is Type:
7 CloneContract{
8 first_dimensions: {Observation.clone_first_dimensions(shape, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
9 second_dimensions: {Observation.clone_second_dimensions(shape, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
10 first_count: {Observation.clone_first_length(shape, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
11 second_count: {Observation.clone_second_length(shape, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
12 first_word_count: {Observation.clone_first_count(shape, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
13 second_word_count: {Observation.clone_second_count(shape, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
14 first_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
15 {Observation.clone_first_value(shape, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>},
16 second_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
17 {Observation.clone_second_value(shape, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>}}
18
19type CloneWrite<-shape: Shape.Shape, -fill: F32, -index: U32, -value: F32> is Type:
20 CloneWrite{
21 written: {Observation.clone_written_first(shape, index, value, index, Core.new(shape, fill)) == Some{value} : Maybe<&2, F32>},
22 frame: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
23 @different: {Nat.is_eq(U32.to_nat(index), U32.to_nat(other)) == False{} : Bool} ->
24 {Observation.clone_written_first(shape, index, value, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>},
25 second: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
26 {Observation.clone_written_second(shape, index, value, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>}}
27
28type MetadataContract<-shape: Shape.Shape, -fill: F32> is Type:
29 MetadataContract{
30 length: {Observation.length_value(shape, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
31 retained_dimensions: {Observation.length_owner_dimensions(shape, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
32 retained_count: {Observation.length_owner_length(shape, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
33 retained_word_count: {Observation.length_owner_count(shape, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
34 shape_dimensions: {Observation.dimensions(shape, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
35 word_count: {Observation.count(shape, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
36 retained_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
37 {Observation.length_owner_value(shape, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>},
38 shape_retained_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
39 {Observation.shape_owner_value(shape, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>},
40 count_retained_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
41 {Observation.count_owner_value(shape, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>}}