~/bend-docscommunity

src/autograd/broadcast_pointwise_PROOF.bend open laws/TODOs

raw source on the hub · import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_PROOF.bend as Broadcast_pointwise_PROOF

21 imports
import Base
import ../shape/core.bend as Shape
import ../storage/LAWS.bend as StorageLaws
import ../storage/arith.bend as Arith
import ../tensor/core.bend as Core
import ../tensor/layout.bend as Layout
import ../tensor/lifecycle.bend as Lifecycle
import ../tensor/elementwise.bend as Elementwise
import ../tensor/word_conversion.bend as Conversion
import ../tensor/contracts/LAWS.bend as Contracts
import ../tensor/contracts/replayed.bend as Replayed
import ../tensor/contracts/pointwise_proof.bend as PointwiseProof
import ../tensor/contracts/broadcast.bend as PointwiseBroadcast
import ../tensor/contracts/binary_LAWS.bend as BinaryLaws
import ../tensor/contracts/binary_proofs.bend as Binary
import ../tensor/contracts/binary_PROOF.bend as BinaryProof
import ./broadcast.bend as Broadcast
import ./reduce_LAWS.bend as ReduceLaws
import ./reduce_fold_PROOF.bend as FoldProof
import ./reduce_to_fold_PROOF.bend as ReduceTo
import ./broadcast_pointwise_LAWS.bend as Laws

Definitions

def cells_keep source · line 25 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+target:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+count:Nat -> {0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/binary_LAWS.cells(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/elementwise.KeepLeft{}, plan, shape, fill, ops, target, 0.0, [], count) == 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.cells(plan, shape, fill, ops, count) : List<&2, F32>}

The pointwise family's KeepLeft words, with the input on the left and the +0.0 tensor of the target on the right, are broadcast_to's cells.

def cells_length source · line 38 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+count:Nat -> {List.length(&2, F32, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.cells(plan, shape, fill, ops, count)) == count : Nat}

def cells_step source · line 51 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+previous:Nat -> @+position:Nat -> @below:{Nat.is_lt(position, 1n+previous) == True{} : Bool} -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<Nat.is_eq(position, previous)> -> @earlier:(@inside:{Nat.is_lt(position, previous) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.cells(plan, shape, fill, ops, previous), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.left_map(plan, position)))} : Maybe<&2, F32>}) -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.cells(plan, shape, fill, ops, 1n+previous), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.left_map(plan, position)))} : Maybe<&2, F32>}

Word position of cells is the input word at left_map(plan, position).

def cells_at source · line 80 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+count:Nat -> @+position:Nat -> @below:{Nat.is_lt(position, count) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.cells(plan, shape, fill, ops, count), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.left_map(plan, position)))} : Maybe<&2, F32>}

def listed_value source · line 95 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+count:Nat -> @+values:List<&2, F32> -> @+index:U32 -> @words:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/LAWS.words(shape, fill, ops, count) == values : List<&2, F32>} -> @below:{Nat.is_lt(U32.to_nat(index), count) == True{} : Bool} -> {Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, index)} == 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(values, U32.to_nat(index)) : Maybe<&2, F32>}

A replayed tensor whose first count words are values holds, below count, the word values lists there.

def run_lift source · line 113 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+target:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+planned:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.broadcast_checked(shape, target) == Done{plan} : Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan>} -> @+same:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(target) : List<&2, U32>} -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-P:(@_:Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>) -> Type) -> @h:0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.BroadcastWith(plan, shape, fill, ops, P) -> @-fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(shape, fill, ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(shape)) : Nat} -> P(0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast.broadcast_to(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{shape, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(shape, fill, ops), fits}}, target))

broadcast_to on a replayed input whose shape broadcasts to exactly the target: the planner and the target check pass, the zero tensor of the target is allocated, and the parallel build runs KeepLeft with the input on the left and the zero tensor on the right, whose words are cells.

def output_below source · line 139 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+target:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+index:U32 -> @same:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(target) : List<&2, U32>} -> @inside:{Nat.is_lt(U32.to_nat(index), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(target))) == True{} : Bool} -> {Nat.is_lt(U32.to_nat(index), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)))) == True{} : Bool}

def broadcast_to_pointwise source · line 147 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+target:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+planned:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.broadcast_checked(shape, target) == Done{plan} : Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan>} -> @+same:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(target) : List<&2, U32>} -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(shape, fill, ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(shape)) : Nat} -> 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast_pointwise_LAWS.BroadcastToContract<target, shape, index => 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.left_map(plan, index))), other => 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, other), 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/broadcast.broadcast_to(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{shape, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(shape, fill, ops), fits}}, target)>