(mode)
| 4 | describe('issue #267 kernel'); |
| 5 | |
| 6 | function immutableKernelWithoutFloats(mode) { |
| 7 | const gpu = new GPU({ mode }); |
| 8 | const kernel = gpu.createKernel(function (v) { |
| 9 | return v[this.thread.x] + 1; |
| 10 | }, { |
| 11 | output: [1], |
| 12 | immutable: true, |
| 13 | pipeline: true, |
| 14 | precision: 'unsigned', |
| 15 | }); |
| 16 | |
| 17 | // start with a value on CPU |
| 18 | const output1 = kernel([1]); |
| 19 | const result1 = output1.toArray()[0]; |
| 20 | |
| 21 | // reuse that output, simulating that this value will be monitored, and updated via the same kernel |
| 22 | // this is often used in neural networks |
| 23 | const output2 = kernel(output1); |
| 24 | const result2 = output2.toArray()[0]; |
| 25 | |
| 26 | const output3 = kernel(output2); |
| 27 | const result3 = output3.toArray()[0]; |
| 28 | |
| 29 | assert.equal(result1, 2); |
| 30 | assert.equal(result2, 3); |
| 31 | assert.equal(result3, 4); |
| 32 | gpu.destroy(); |
| 33 | } |
| 34 | |
| 35 | test('Issue #267 immutable kernel output without floats - auto', () => { |
| 36 | immutableKernelWithoutFloats(); |
no test coverage detected
searching dependent graphs…