1 import Base 2 import ../shape/core.bend as Shape 3 import ./core.bend as Core 4 import ./allocation_spec.bend as Allocation 5 import ./observation.bend as Observation 6 import ./construction_metadata.bend as Metadata 7 8 type NewReads<-shape: Shape.Shape, -fill: F32, -index: U32> is Type: 9 NewReads{ 10 successful: {Result.is_done(&2, &1, Core.Error, Core.Tensor, 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 21 law new_metadata: 22 for +shape: Shape.Shape 23 for +fill: F32 24 Metadata.NewMetadata 25 26 law 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