compute.kernels.max¶
Summary¶
compute.kernels.max reduces a non-empty real GPU ndarray to its largest value. Use it for a single upper bound over a strided or packed array. For per-axis bounds or both endpoints in one call, use compute.ndarray.minMax.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
a |
GPUndarray |
Yes | Non-empty f32 or u32 array of any supported shape and layout. |
opts |
KernelOutputOptions |
No | Kernel output and dispatch settings. |
Returns¶
GPUndarray - Scalar of shape [] and the input dtype. NaN propagates and positive zero is ordered above negative zero. Empty input throws.
Example¶
const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const { ndarray: nd, kernels } = wgpu.compute;
const a = nd.fromArray("u32", [3], [5, 2, 9], { residency: "gpu" });
const high = kernels.max(a);
const cpu = await nd.toCPU(high);
console.log(cpu.get()); // 9
cpu.destroy();
high.destroy();
a.destroy();