src/tensor/construction_contract_LAWS.bend

bendtorch-core@0.1.0.0 · 31 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/allocation_spec.bend as Allocation
5import bendtorch-core@0.1.0.0/src/tensor/observation.bend as Observation
6import bendtorch-core@0.1.0.0/src/tensor/construction_metadata.bend as Metadata
7
8type NewReads<-shape: Shape.Shape, -fill: F32, -index: U32> is Type:
9  NewReads{
10    successful: {Result.is_done(&2, &1, Core.Error, Core.Tensor<shape>, Core.new(shape, fill)) == True{} : Bool},
11    dimensions: {Observation.dimensions(shape, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
12    count: {Allocation.tensor_length(shape, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
13    word_count: {Observation.count(shape, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
14    value: {Observation.point(shape, index, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>},
15    retained_dimensions: {Observation.after_dimensions(shape, index, Core.new(shape, fill)) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
16    retained_count: {Observation.after_length(shape, index, Core.new(shape, fill)) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
17    retained_word_count: {Observation.after_count(shape, index, Core.new(shape, fill)) == Some{Shape.count(shape)} : Maybe<&2, U32>},
18    retained_value: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool} ->
19      {Observation.after_value(shape, index, other, Core.new(shape, fill)) == Some{fill} : Maybe<&2, F32>}}
20
21law new_metadata:
22  for +shape: Shape.Shape
23  for +fill: F32
24  Metadata.NewMetadata<shape, fill>
25
26law new_reads:
27  for +shape: Shape.Shape
28  for +fill: F32
29  for +index: U32
30  for inside: {Nat.is_lt(U32.to_nat(index), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool}
31  NewReads<shape, fill, index>