compute.ndarray#base¶
Summary¶
compute.ndarray#base identifies the root array that backs a view. A view of a view points directly to the same root.
Syntax¶
Returns¶
Ndarray | null - Root of a metadata view, or null for an array created directly. An array created by wrapping external storage also has base === null.
Example¶
const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const nd = wgpu.compute.ndarray;
const values = nd.fromArray("f32", [3], [1, 2, 3]);
const suffix = nd.slice(values, "1:");
const reverse = nd.flip(suffix);
suffix.destroy();
console.log(reverse.base === values, reverse.get(0)); // true, 3
reverse.destroy();
values.destroy();
Notes¶
Destroying a view releases its own metadata and leaves the root usable. Destroying the root invalidates every view over it. Mutating shared values through a view is visible to the root and to views of the same elements.