(mode)
| 53 | }); |
| 54 | |
| 55 | function 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(); |
no test coverage detected
searching dependent graphs…