@saehrimnir/druidjs / setWasmEnabled
Function: setWasmEnabled()
function setWasmEnabled(enabled: boolean): boolean;Defined in: wasm/index.js:60
Enables or disables WASM acceleration at runtime.
With WASM disabled every accelerated function takes its JS fallback path. This exists so the two implementations can be compared in tests and benchmarks.
For most of the library the two paths agree to within floating point tolerance — the kernels accumulate in a different order than the scalar loops, and Math.pow/Math.exp are only "implementation-approximated" in ECMAScript, so the last bit may differ. PCA, MDS, TSNE and TriMap come out bit-identical in practice.
UMAP and SAMMON are the exception: their optimisers are chaotic, so a last-bit difference grows into a visibly different (though equally valid) layout. See the note on reproducibility in those classes.
Parameters
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | Whether kernels may run in WASM. |
Returns
boolean
The new state.
Example
import { setWasmEnabled } from "@saehrimnir/druidjs";
setWasmEnabled(false); // force the pure JS implementations