MCPcopy Create free account
hub / github.com/gpujs/gpu.js / immutableKernelWithFloats

Function immutableKernelWithFloats

test/issues/267-immutable-sub-kernels.js:55–77  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

53});
54
55function immutableKernelWithFloats(mode) {
56 const gpu = new GPU({ mode });
57 const kernel = gpu.createKernel(function (v) {
58 return v[this.thread.x] + 1;
59 }, {
60 output: [1],
61 immutable: true,
62 pipeline: true,
63 precision: 'single',
64 });
65
66 // start with a value on CPU
67 // reuse that output, simulating that this value will be monitored, and updated via the same kernel
68 // this is often used in neural networks
69 const output1 = kernel([1]);
70 const output2 = kernel(output1);
71 const output3 = kernel(output2);
72
73 assert.equal(output1.toArray()[0], 2);
74 assert.equal(output2.toArray()[0], 3);
75 assert.equal(output3.toArray()[0], 4);
76 gpu.destroy();
77}
78
79(GPU.isSinglePrecisionSupported ? test : skip)('Issue #267 immutable kernel output with floats - auto', () => {
80 immutableKernelWithFloats();

Callers 1

Calls 4

createKernelMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
toArrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…