def run
stelliferous@0.0.2.0 · traversal_partition.bend:10
import stelliferous@0.0.2.0/traversal_partition.bend as TraversalPartition
import Base
import stelliferous@0.0.2.0/storage_buffer.bend as Storage
10
11
12
13
14
15
16
17
18def run(~Input: Type,~Weights: Type,~Bias: Type,~Output: Type,~Context: Data,
19 ~split_input: Context -> U32 -> U32 -> Input -> Input & Input,~clone_weights: Weights -> Weights & Weights,~clone_bias: Bias -> Bias & Bias,
20 ~leaf: Context -> U32 -> U32 -> Input -> Weights -> Bias -> Tree<&1,Output,U32>,
21 depth: Nat,+context: Context,+offset: U32,+span: U32,input: Input,weights: Weights,bias: Bias) -> Tree<&1,Output,U32>:
22 match depth:
23 case 0n: leaf(context,offset,span,input,weights,bias)
24 case 1n:
25 +half = (span / 16 * 8 : U32)
26 Storage.bind_pair(~Input,~Input,~Tree<&1,Output,U32>,split_input(context,offset,half,input),left_input => right_input =>
27 Storage.bind_pair(~Weights,~Weights,~Tree<&1,Output,U32>,clone_weights(weights),left_weights => right_weights =>
28 Storage.bind_pair(~Bias,~Bias,~Tree<&1,Output,U32>,clone_bias(bias),left_bias => right_bias =>
29 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)
30 Fork{left,right})))
31 case 2n+ +rest:
32 +half = (span / 16 * 8 : U32)
33 Storage.bind_pair(~Input,~Input,~Tree<&1,Output,U32>,split_input(context,offset,half,input),left_input => right_input =>
34 Storage.bind_pair(~Weights,~Weights,~Tree<&1,Output,U32>,clone_weights(weights),left_weights => right_weights =>
35 Storage.bind_pair(~Bias,~Bias,~Tree<&1,Output,U32>,clone_bias(bias),left_bias => right_bias =>
36 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)
37 Fork{left,right})))