def bmv

bend-ml-tensor-array@0.1.19.0 · main.bend:1686

import bend-ml-tensor-array@0.1.19.0/main.bend as BendMlTensorArray
import Base

1686# the two bands of a node run in parallel, each with its own copy of x (c numbers);
1687# xp is a pair of copies of x (a leaf uses one). xp comes after the erased e: up to Bend 2.0.36 an erased
1688# parameter at the end of the list turned the parallel let into two sequential calls (NOTES.md, exp. 11; fixed in
1689# 2.0.37 by bendlang/bend#1377). The order is kept, and harmless.
1690def bmv(+c: Nat, -r: Nat, b: Bands<r, c>, +rr: Nat, -e: {rr == r : Nat}, xp: Array<F32> & Array<F32>) -> BL<r, c>:
1691  match b xp:
1692    case BLeaf{m} Tuple{x, x2}:
1693      bv_mat(r, c, rr, x, m)
1694    case BNode{bx, by} Tuple{x1, x2}:
1695      p q = bmv(c, half(r), bx, half(rr), eq_half(rr, r, e), Array.clone(F32, x1)) bmv(c, Nat.sub(r, half(r)), by, Nat.sub(rr, half(rr)), eq_rest(rr, r, e), Array.clone(F32, x2))
1696      bv_join(r, c, p, q)

Uses (14)

Used by (2)