Spec.bal: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/spec.bend as Spec Lines 166-173 of bendtorch@1.3.0.0/spec.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/spec.bend&start_line=166&end_line=173 import Base # the 2^p cells from cell i summed as a balanced tree of pairs: how a GPU leaf sums its block (the device's MSE and # cross-entropy block sums) def bal(+p: Nat, +i: Nat) -> Sum: match p: case 0n: SCell{i} case 1n+q: SAdd{bal(q, i), bal(q, Nat.add(i, pw(q)))} Uses (4): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=Sum https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=pw