def product_build

bendtorch-core@0.1.0.0 · src/tensor/matmul.bend:621

import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matmul
import Base
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/parallel.bend as Parallel

621# The parallel product build: the top `splits` levels fork as
622# `Parallel.build` forks, each half with its own copy of both inputs, and
623# each subtree below the forks is a `product_tree`.
624def product_build(+depth: Nat, +splits: Nat, +lo: Order, +ro: Order, +inner: Nat, +rows: Nat, +columns: Nat,
625  +count: Nat, +base: Nat, la: Array<F32>, ra: Array<F32>) -> Array<F32>:
626  match depth splits:
627    case 1n+lower 1n+rest:
628      Parallel.fork(~Array<F32>, ~Array<F32>, Elementwise.split((la, ra)),
629        l => r => product_build(lower, rest, lo, ro, inner, rows, columns, count, base, l, r),
630        l => r => product_build(lower, rest, lo, ro, inner, rows, columns, count, Parallel.upper(lower, base), l, r))
631    case _ _:
632      Pair.fst(Array<F32>, Array<F32> & Array<F32>, product_tree(Layout{lo, ro, inner, rows, columns}, depth, count, base, (la, ra)))

Uses (12)

Used by (6)