src/tensor/contracts/binary_LAWS.bend open laws/TODOs
raw source on the hub · import bendtorch-core@0.1.0.0/src/tensor/contracts/binary_LAWS.bend as Binary_LAWS
10 imports
import Base import ../../shape/core.bend as Shape import ../../storage/LAWS.bend as StorageLaws import ../core.bend as Core import ../lifecycle.bend as Lifecycle import ../elementwise.bend as Elementwise import ./replayed.bend as Replayed import ./pointwise.bend as Pointwise import ./broadcast.bend as Broadcast import ./LAWS.bend as Contracts
Laws
law binary_replayed provedin PROOF.bendsource · line 59 · raw
@+operation:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/elementwise.Operation -> @+left:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+right:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @planned:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.broadcast_checked(left, right) == Done{plan} : Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan>} -> @+left_fill:F32 -> @+left_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-left_fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(left, left_fill, left_ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(left)) : Nat} -> @+right_fill:F32 -> @+right_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-right_fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(right, right_fill, right_ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(right)) : Nat} -> @-P:(@_:Pair(Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic), Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>) -> Type) -> @h:BinaryWith(operation, plan, left, left_fill, left_ops, right, right_fill, right_ops, P) -> P(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/elementwise.binary(operation, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{left, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(left, left_fill, left_ops), left_fits}}, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{right, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(right, right_fill, right_ops), right_fits}}))The parallel elementwise build exports its replayed result. For two
replayed inputs whose shapes broadcast, for every P, if P holds for every
result that hands back both inputs with their words and gives an output of
the plan's shape whose words are cells, then P holds for
Elementwise.binary. The output word at k is the value the pointwise family
writes at k, whatever split of the output into parallel halves the build
takes, and the output is a replayed tensor, so a law about replayed tensors
applies to it.
Definitions
def cells source · line 15 · raw
@+operation:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/elementwise.Operation -> @+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+left:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+left_fill:F32 -> @+left_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+right:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+right_fill:F32 -> @+right_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+count:Nat -> List<&2, F32>
The words of a pointwise product in index order: word k is scalar(operation, left[left_map(plan, k)], right[right_map(plan, k)]), the value the pointwise family's broadcast instance writes at k.
def BinaryWith source · line 29 · raw
@+operation:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/elementwise.Operation -> @+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+left:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+left_fill:F32 -> @+left_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+right:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+right_fill:F32 -> @+right_ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-P:(@_:Pair(Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic), Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>) -> Type) -> Type
What the transport form of binary_replayed asks of P: P holds for both
inputs, replayed with any histories that keep their words, next to the
output replayed over +0.0 with any history whose words are cells.