TraversalPartition.run: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/traversal_partition.bend as TraversalPartition Lines 10-37 of stelliferous@0.0.2.0/traversal_partition.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/traversal_partition.bend&start_line=10&end_line=37 import Base import stelliferous@0.0.2.0/storage_buffer.bend as Storage # Each binary fork gives both children independent owners; its leaf callback # finishes all local stages before returning. The input split sees the left # child's range, so it can copy only what that child reads. Representation # adapters supply direct templates, so Array and certified Buffer share it. # The last split calls its two leaves directly: a leaf that neither forks nor # calls a closure is then its own task, which the runtime keeps for the work # turn; a leaf reached through the forking recursion would run in the grow # turn on one worker per row. def run(~Input: Type,~Weights: Type,~Bias: Type,~Output: Type,~Context: Data, ~split_input: Context -> U32 -> U32 -> Input -> Input & Input,~clone_weights: Weights -> Weights & Weights,~clone_bias: Bias -> Bias & Bias, ~leaf: Context -> U32 -> U32 -> Input -> Weights -> Bias -> Tree<&1,Output,U32>, depth: Nat,+context: Context,+offset: U32,+span: U32,input: Input,weights: Weights,bias: Bias) -> Tree<&1,Output,U32>: match depth: case 0n: leaf(context,offset,span,input,weights,bias) case 1n: +half = (span / 16 * 8 : U32) Storage.bind_pair(~Input,~Input,~Tree<&1,Output,U32>,split_input(context,offset,half,input),left_input => right_input => Storage.bind_pair(~Weights,~Weights,~Tree<&1,Output,U32>,clone_weights(weights),left_weights => right_weights => Storage.bind_pair(~Bias,~Bias,~Tree<&1,Output,U32>,clone_bias(bias),left_bias => right_bias => left right = leaf(context,offset,half,left_input,left_weights,left_bias) leaf(context,(offset + half : U32),(span - half : U32),right_input,right_weights,right_bias) Fork{left,right}))) case 2n+ +rest: +half = (span / 16 * 8 : U32) Storage.bind_pair(~Input,~Input,~Tree<&1,Output,U32>,split_input(context,offset,half,input),left_input => right_input => Storage.bind_pair(~Weights,~Weights,~Tree<&1,Output,U32>,clone_weights(weights),left_weights => right_weights => Storage.bind_pair(~Bias,~Bias,~Tree<&1,Output,U32>,clone_bias(bias),left_bias => right_bias => left right = run(~Input,~Weights,~Bias,~Output,~Context,~split_input,~clone_weights,~clone_bias,~leaf,1n+rest,context,offset,half,left_input,left_weights,left_bias) run(~Input,~Weights,~Bias,~Output,~Context,~split_input,~clone_weights,~clone_bias,~leaf,1n+rest,context,(offset + half : U32),(span - half : U32),right_input,right_weights,right_bias) Fork{left,right}))) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/storage_buffer.bend&name=bind_pair https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/traversal_partition.bend&name=Tree