def metadata_contract
bendtorch-core@0.1.0.0 · src/tensor/metadata_contract.bend:78
import bendtorch-core@0.1.0.0/src/tensor/metadata_contract.bend as MetadataContract
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/observation.bend as Observation
import bendtorch-core@0.1.0.0/src/tensor/read_contract.bend as Reads
import bendtorch-core@0.1.0.0/src/tensor/clone_metadata_records.bend as Laws
78def metadata_contract(+shape: Shape.Shape, +fill: F32) -> Laws.MetadataContract<shape, fill>:
79 Laws.MetadataContract{
80 Reads.new_lift(shape, fill, result => {Observation.length_value(shape, result) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
81 valid => length_done(shape, fill, valid)),
82 Reads.new_lift(shape, fill, result => {Observation.length_owner_dimensions(shape, result) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
83 valid => owner_dimensions_pair(shape, Core.length(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
84 Reads.new_lift(shape, fill, result => {Observation.length_owner_length(shape, result) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
85 valid => owner_length_done(shape, fill, valid)),
86 Reads.new_lift(shape, fill, result => {Observation.length_owner_count(shape, result) == Some{Shape.count(shape)} : Maybe<&2, U32>},
87 valid => owner_count_pair(shape, Core.length(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
88 Reads.new_lift(shape, fill, result => {Observation.dimensions(shape, result) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
89 valid => {==}),
90 Reads.new_lift(shape, fill, result => {Observation.count(shape, result) == Some{Shape.count(shape)} : Maybe<&2, U32>},
91 valid => {==}),
92 other => inside => Reads.new_lift(shape, fill, result => {Observation.length_owner_value(shape, other, result) == Some{fill} : Maybe<&2, F32>},
93 valid => owner_value_done(shape, fill, valid, other, inside)),
94 other => inside => Reads.new_lift(shape, fill, result => {Observation.shape_owner_value(shape, other, result) == Some{fill} : Maybe<&2, F32>},
95 valid => dynamic_value_done(shape, fill, valid, other, inside)),
96 other => inside => Reads.new_lift(shape, fill, result => {Observation.count_owner_value(shape, other, result) == Some{fill} : Maybe<&2, F32>},
97 valid => dynamic_value_done(shape, fill, valid, other, inside))}