gpuMap (Function)
Signature: gpuMap(buffer: GpuBuffer<int> | GpuBuffer<float> | GpuBuffer<bool>, kernel: (t0) -> t1) -> GpuBuffer<t1>
Description: Applies a pure kernel to every buffer element independently. The compiler rejects a kernel that performs any effect a handler must discharge at runtime; an effect a static handler has already erased is gone before the check.
Parameters
- buffer (GpuBuffer
| GpuBuffer | GpuBuffer ): The source buffer - kernel ((t0) -> t1): The pure per-element function
Returns: GpuBuffer
Example
toGpu([1, 2, 3]) |> gpuMap(fn(x) => (x * x) ?: 0)
toGpu [1, 2, 3] |> gpuMap (\x => (x * x) ?: 0)