def broadcast_pointwise
bendtorch-core@0.1.0.0 · src/tensor/contracts/broadcast_proof.bend:89
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast_proof.bend as BroadcastProof
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/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/word_conversion.bend as Conversion
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise_proof.bend as Proof
import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise_records.bend as Records
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast.bend as Broadcast
89def broadcast_pointwise(+operation: Elementwise.Operation, +plan: Shape.BroadcastPlan,
90 +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>,
91 -left_fits: {Lifecycle.logical_length(Replayed.storage(Shape.left_shape(plan), left_fill, left_ops)) ==
92 Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan))) : Nat},
93 +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>,
94 -right_fits: {Lifecycle.logical_length(Replayed.storage(Shape.right_shape(plan), right_fill, right_ops)) ==
95 Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan))) : Nat}) ->
96 Records.PointwiseContract<Shape.output_shape(plan), Shape.left_shape(plan), Shape.right_shape(plan),
97 index => Broadcast.cell(operation, plan, left_fill, left_ops, right_fill, right_ops, index),
98 other => Replayed.value(Shape.left_shape(plan), left_fill, left_ops, other),
99 other => Replayed.value(Shape.right_shape(plan), right_fill, right_ops, other),
100 Broadcast.binary(operation, plan,
101 Core.Packed{Shape.left_shape(plan), Core.TTensor{Replayed.storage(Shape.left_shape(plan), left_fill, left_ops), left_fits}},
102 Core.Packed{Shape.right_shape(plan), Core.TTensor{Replayed.storage(Shape.right_shape(plan), right_fill, right_ops), right_fits}})>:
103 +total = Shape.logical_numel(Shape.dimensions(Shape.output_shape(plan)))
104 Proof.contract(~Elementwise.Operation, ~Elementwise.scalar, ~Shape.BroadcastPlan, ~Broadcast.left_map, ~Broadcast.right_map,
105 operation, plan, Shape.left_shape(plan), left_fill, left_ops, Shape.right_shape(plan), right_fill, right_ops, Shape.output_shape(plan),
106 left_inside(plan, total, Conversion.le_reflexive(total)), right_inside(plan, total, Conversion.le_reflexive(total)), left_fits, right_fits)