(mode)
| 588 | |
| 589 | |
| 590 | function dynamicOutput3DShrinks(mode) { |
| 591 | const gpu = new GPU({ mode }); |
| 592 | const kernel = gpu.createKernel(function() { |
| 593 | return this.output.x + this.output.y + this.thread.z + this.thread.x + this.thread.y + this.thread.z; |
| 594 | }, { dynamicOutput: true }); |
| 595 | |
| 596 | kernel.setOutput([3,3,3]); |
| 597 | let result = kernel(); |
| 598 | assert.equal(result.length, 3); |
| 599 | assert.deepEqual(result.map(matrix => matrix.map(row => Array.from(row))), [ |
| 600 | [ |
| 601 | [6,7,8], |
| 602 | [7,8,9], |
| 603 | [8,9,10] |
| 604 | ], |
| 605 | [ |
| 606 | [8,9,10], |
| 607 | [9,10,11], |
| 608 | [10,11,12] |
| 609 | ], |
| 610 | [ |
| 611 | [10,11,12], |
| 612 | [11,12,13], |
| 613 | [12,13,14] |
| 614 | ] |
| 615 | ]); |
| 616 | assert.deepEqual(Array.from(kernel.output), [3,3,3]); |
| 617 | |
| 618 | kernel.setOutput([2,2,2]); |
| 619 | result = kernel(); |
| 620 | assert.equal(result.length, 2); |
| 621 | assert.deepEqual(result.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]); |
| 622 | assert.deepEqual(Array.from(kernel.output), [2,2,2]); |
| 623 | |
| 624 | gpu.destroy(); |
| 625 | } |
| 626 | |
| 627 | test('dynamic output 3d shrinks auto', () => { |
| 628 | dynamicOutput3DShrinks(); |
no test coverage detected
searching dependent graphs…