def fpar

bendtorch@1.3.0.0 · main.bend:2787

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base
import bend-ml-tensor-array@0.1.18.0/main.bend as TA

2787# the n sequences of gs (cut in two halves) in a tree of parallel lets of depth d; the outputs come back in order
2788def fpar(d: Nat, gs: Halves<FS>, +n: Nat, +h: Nat, +dm: Dm) -> List<&1, Array<F32>>:
2789  match d gs:
2790    case 0n Halves{l, r}:
2791      a b = fleaf(l, h, dm, Nil{}) fleaf(r, h, dm, Nil{})
2792      List.append(&1, Array<F32>, a, b)
2793    case 1n++e Halves{l, r}:
2794      a b = fpar(e, cut(FS, TA.half(TA.half(n)), l, Nil{}), TA.half(n), h, dm) fpar(e, cut(FS, TA.half(Nat.sub(n, TA.half(n))), r, Nil{}), Nat.sub(n, TA.half(n)), h, dm)
2795      List.append(&1, Array<F32>, a, b)

Uses (12)

Used by (6)