WasmGPU.compute.ndarray.ndim¶
Summary¶
WasmGPU.compute.ndarray.ndim reports the rank (number of dimensions) of an ndarray instance.
This applies to both CPUndarray and GPUndarray because both inherit from Ndarray.
Use it for dimension checks and generic kernel-shape logic.
It is derived from shape.length.
Syntax¶
Parameters¶
This API does not take parameters.
Returns¶
number - Number of dimensions in the ndarray shape.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const a = wgpu.compute.CPUndarray.empty("f32", { shape: [64, 32, 8] });
console.log(a.ndim);