gpuScan (Function)
Signature: gpuScan(buffer: GpuBuffer<int> | GpuBuffer<float> | GpuBuffer<bool>, initial: t0, combine: (t0, t0) -> t0) -> GpuBuffer<t0>
Description: Inclusive prefix scan: element i is combine folded through element i. Use an associative combine: a device backend may run it work-efficiently in parallel.
Parameters
- buffer (GpuBuffer
| GpuBuffer | GpuBuffer ): The buffer to scan - initial (t0): The initial scalar accumulator
- combine ((t0, t0) -> t0): The pure (accumulator, element) function
Returns: GpuBuffer
Example
toGpu([1, 2, 3]) |> gpuScan(0, fn(a, x) => (a + x) ?: a) // 1, 3, 6
toGpu [1, 2, 3] |> gpuScan (0, \(a, x) => (a + x) ?: a) // 1, 3, 6