~/bend-docscommunity

src/autograd/reduce_fold_PROOF.bend open laws/TODOs

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

24 imports
import Base
import ../shape/core.bend as Shape
import ../shape/LAWS.bend as ShapeLaws
import ../shape/PROOF.bend as ShapeProof
import ../storage/LAWS.bend as StorageLaws
import ../storage/arith.bend as Arith
import ../tensor/core.bend as Core
import ../tensor/lifecycle.bend as Lifecycle
import ../tensor/word_conversion.bend as Conversion
import ../tensor/projection_LAWS.bend as Projection
import ../tensor/contracts/replayed.bend as Replayed
import ../tensor/contracts/pointwise.bend as Pointwise
import ../tensor/contracts/pointwise_proof.bend as PointwiseProof
import ../tensor/contracts/broadcast.bend as Broadcast
import ../tensor/contracts/broadcast_proof.bend as BroadcastProof
import ../tensor/contracts/fold.bend as Fold
import ../tensor/contracts/fold_records.bend as Records
import ../tensor/contracts/fold_proof.bend as FoldProof
import ../tensor/contracts/sum.bend as Sum
import ../tensor/contracts/LAWS.bend as Contracts
import ../tensor/contracts/PROOF.bend as ContractsProof
import ./reduce_LAWS.bend as ReduceLaws
import ./reduce_fold.bend as ReduceFold
import ./reduce_fold_LAWS.bend as Laws

Definitions

def offsets_walk source · line 26 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+map:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Index<0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.left_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan))> -> @+position:Nat -> @+bound:{True{} == Nat.is_lt(position, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan))) : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/projection_LAWS.offset_spec(plan, position) == Some{(U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.left_walk(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.left_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)), map, position)), U32.from_nat(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/broadcast.right_walk(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.left_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)), map, position)))} : Maybe<&1, Pair(U32, U32)>}

def length_snoc source · line 57 · raw

@+values:List<&2, F32> -> @+word:F32 -> {List.length(&2, F32, List.append(&2, F32, values, [word])) == 1n+List.length(&2, F32, values) : Nat}

def words_length source · line 66 · raw

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

def word_at_front source · line 78 · raw

@+values:List<&2, F32> -> @+word:F32 -> @+position:Nat -> @below:{Nat.is_lt(position, List.length(&2, F32, values)) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(List.append(&2, F32, values, [word]), position) == 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(values, position) : Maybe<&2, F32>}

def word_at_last source · line 89 · raw

@+values:List<&2, F32> -> @+word:F32 -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(List.append(&2, F32, values, [word]), List.length(&2, F32, values)) == Some{word} : Maybe<&2, F32>}

def words_step source · line 97 · raw

@+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/tensor/contracts/LAWS.words(shape, fill, ops, previous), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(position))} : Maybe<&2, F32>}) -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.word_at(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/LAWS.words(shape, fill, ops, 1n+previous), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(position))} : Maybe<&2, F32>}

def words_at source · line 125 · raw

@+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/tensor/contracts/LAWS.words(shape, fill, ops, count), position) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(shape, fill, ops, U32.from_nat(position))} : Maybe<&2, F32>}

def matched_chosen source · line 137 · raw

@+same:Bool -> @+total:F32 -> @+word:F32 -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.matched(Some{total}, Some{word}, same) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/fold.chosen(Unit, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/sum.add, Unit{}, same, total, word)} : Maybe<&2, F32>}

def fiber_total source · line 145 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+index:U32 -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+count:Nat -> @+room:{Nat.is_le(count, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)))) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.fiber(plan, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/LAWS.words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)))), index, count) == Some{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/fold.total(Unit, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/sum.add, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.source, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.lands, Unit{}, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell{plan, index}, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, count)} : Maybe<&2, F32>}

def source_inside source · line 186 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+index:U32 -> @+count:Nat -> @+room:{Nat.is_le(count, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)))) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/pointwise.inside(0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.source, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell{plan, index}, count, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)))) == True{} : Bool}

def contribution_room source · line 205 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @same:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)) : List<&2, Nat>} -> {Nat.is_le(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)))) == True{} : Bool}

def fiber_contract source · line 216 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @+index:U32 -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan))) : Nat} -> @+expected:Maybe<&2, F32> -> @+total:F32 -> @+count:Nat -> @evidence:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/fold_records.FoldContract<0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), total, other => 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, other), 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/fold.run(Unit, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/sum.add, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.source, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.lands, Unit{}, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell{plan, index}, count, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops), fits}})> -> @equation:{expected == Some{total} : Maybe<&2, F32>} -> 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold_LAWS.FiberContract<0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), expected, other => 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, other), 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/fold.run(Unit, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/sum.add, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.source, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.lands, Unit{}, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.Cell{plan, index}, count, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops), fits}})>

def reduce_fold_fiber source · line 237 · raw

@+plan:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BroadcastPlan -> @same:{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.output_shape(plan)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.extents(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)) : List<&2, Nat>} -> @+index:U32 -> @+fill:F32 -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @-fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/lifecycle.logical_length(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops)) == 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan))) : Nat} -> 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold_LAWS.FiberContract<0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_LAWS.fiber(plan, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/LAWS.words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)))), index, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.logical_numel(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan)))), other => 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.value(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops, other), 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce_fold.cell(plan, index, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Packed{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.TTensor{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/replayed.storage(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.right_shape(plan), fill, ops), fits}})>