Skip to content

compute.kernels.argminF32

Summary

compute.kernels.argminF32 finds the index/value pair for the minimum f32 element. It is a convenience wrapper over argReduceF32(input, "argmin", opts). Output uses the same 8-byte pair layout: value bits and index. Use this when you need the location of the smallest value. Ties select the lowest index, and NaNs are ignored. Count, output, encoder, ownership, finite-input requirements, and empty-input behavior match argReduceF32.

Syntax

WasmGPU.compute.kernels.argminF32(input: StorageBuffer, opts?: ArgReduceOptions): StorageBuffer
const out = wgpu.compute.kernels.argminF32(input, opts);

Parameters

Name Type Required Description
input StorageBuffer Yes Source float buffer.
opts ArgReduceOptions No Optional execution settings.

Returns

StorageBuffer - 8-byte result buffer containing minimum value bits and index.

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const input = wgpu.compute.createStorageBuffer({ data: new Float32Array([3, -2, 1, 8]), copySrc: true });
const out = wgpu.compute.kernels.argminF32(input);
const view = new DataView(await wgpu.compute.readback.read(out, 0, 8));
console.log(view.getFloat32(0, true), view.getUint32(4, true));

See Also