def split_pick
import bend-ml-tensor-array@0.1.19.0/main.bend as BendMlTensorArrayimport Base
1185# ---- the split depth of a product (0.1.11.0): par is an upper bound, and a product too small to gain splits 0 times ----
1186#
1187# A product of n x k by k x m splits into 2^par blocks only when it does at least 2^23 multiply-adds and each cell of C
1188# sums at least 64 of them; otherwise it runs sequentially. Measured on 16 threads (2026-10-16, 18 shapes): below 2^23 the
1189# split costs more than it saves, and with a short inner dimension (a weight gradient over a few tokens) every split
1190# was 2-3.6x slower, because each block hands its rows of C back as a list that is then written into C, a cost per cell
1191# of C that k multiply-adds per cell do not pay for. The result does not depend on the depth: the same bits at every
1192# depth (tests/t8.bend, tests/acc.bend, tests/split.bend).
1193def split_pick(big: Bool, d: Nat) -> Nat:
1194 match big:
1195 case True{}:
1196 d
1197 case False{}:
1198 0n