def clone_contract

bendtorch-core@0.1.0.0 · src/tensor/clone_contract.bend:159

import bendtorch-core@0.1.0.0/src/tensor/clone_contract.bend as CloneContract
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

159def clone_contract(+shape: Shape.Shape, +fill: F32) -> Laws.CloneContract<shape, fill>:
160  Laws.CloneContract{
161    Reads.new_lift(shape, fill, result => {Observation.clone_first_dimensions(shape, result) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
162      valid => first_dimensions_pair(shape, Core.clone(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
163    Reads.new_lift(shape, fill, result => {Observation.clone_second_dimensions(shape, result) == Some{Shape.dimensions(shape)} : Maybe<&2, List<&2, U32>>},
164      valid => second_dimensions_pair(shape, Core.clone(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
165    Reads.new_lift(shape, fill, result => {Observation.clone_first_length(shape, result) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
166      valid => first_length_done(shape, fill, valid)),
167    Reads.new_lift(shape, fill, result => {Observation.clone_second_length(shape, result) == Some{Shape.logical_numel(Shape.dimensions(shape))} : Maybe<&2, Nat>},
168      valid => second_length_done(shape, fill, valid)),
169    Reads.new_lift(shape, fill, result => {Observation.clone_first_count(shape, result) == Some{Shape.count(shape)} : Maybe<&2, U32>},
170      valid => first_count_pair(shape, Core.clone(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
171    Reads.new_lift(shape, fill, result => {Observation.clone_second_count(shape, result) == Some{Shape.count(shape)} : Maybe<&2, U32>},
172      valid => second_count_pair(shape, Core.clone(shape, Core.TTensor{StorageLaws.created(Shape.count(shape), fill), valid}))),
173    other => inside => Reads.new_lift(shape, fill, result => {Observation.clone_first_value(shape, other, result) == Some{fill} : Maybe<&2, F32>},
174      valid => first_value_done(shape, fill, valid, other, inside)),
175    other => inside => Reads.new_lift(shape, fill, result => {Observation.clone_second_value(shape, other, result) == Some{fill} : Maybe<&2, F32>},
176      valid => second_value_done(shape, fill, valid, other, inside))}

Uses (30)

Used by (1)