(mode)
| 248 | |
| 249 | |
| 250 | function dynamicOutput2DShrinks(mode) { |
| 251 | const gpu = new GPU({ mode }); |
| 252 | const kernel = gpu.createKernel(function() { |
| 253 | return this.output.x + this.output.y + this.thread.x + this.thread.y; |
| 254 | }, { dynamicOutput: true }); |
| 255 | |
| 256 | kernel.setOutput([3,3]); |
| 257 | let result = kernel(); |
| 258 | assert.equal(result.length, 3); |
| 259 | assert.deepEqual(result.map(row => Array.from(row)), [[6,7,8],[7,8,9],[8,9,10]]); |
| 260 | assert.deepEqual(Array.from(kernel.output), [3,3]); |
| 261 | |
| 262 | kernel.setOutput([2,2]); |
| 263 | result = kernel(); |
| 264 | assert.equal(result.length, 2); |
| 265 | assert.deepEqual(result.map(row => Array.from(row)), [[4,5],[5,6]]); |
| 266 | assert.deepEqual(Array.from(kernel.output), [2,2]); |
| 267 | |
| 268 | gpu.destroy(); |
| 269 | } |
| 270 | |
| 271 | test('dynamic output 2d shrinks auto', () => { |
| 272 | dynamicOutput2DShrinks(); |
no test coverage detected
searching dependent graphs…