MCPcopy Index your code
hub / github.com/gpujs/gpu.js / dynamicOutput3DKernelMapShrinks

Function dynamicOutput3DKernelMapShrinks

test/features/dynamic-output.js:737–796  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

735
736
737function dynamicOutput3DKernelMapShrinks(mode) {
738 const gpu = new GPU({ mode });
739 const kernel = gpu.createKernelMap({
740 result1: function map(v) {
741 return v;
742 }
743 }, function() {
744 return map(this.output.x + this.output.y + this.thread.z + this.thread.x + this.thread.y + this.thread.z);
745 }, { dynamicOutput: true });
746
747 kernel.setOutput([3,3,3]);
748 let result = kernel();
749 assert.equal(result.result.length, 3);
750 assert.equal(result.result1.length, 3);
751 assert.deepEqual(result.result.map(matrix => matrix.map(row => Array.from(row))), [
752 [
753 [6,7,8],
754 [7,8,9],
755 [8,9,10]
756 ],
757 [
758 [8,9,10],
759 [9,10,11],
760 [10,11,12]
761 ],
762 [
763 [10,11,12],
764 [11,12,13],
765 [12,13,14]
766 ]
767 ]);
768 assert.deepEqual(result.result1.map(matrix => matrix.map(row => Array.from(row))), [
769 [
770 [6,7,8],
771 [7,8,9],
772 [8,9,10]
773 ],
774 [
775 [8,9,10],
776 [9,10,11],
777 [10,11,12]
778 ],
779 [
780 [10,11,12],
781 [11,12,13],
782 [12,13,14]
783 ]
784 ]);
785 assert.deepEqual(Array.from(kernel.output), [3,3,3]);
786
787 kernel.setOutput([2,2,2]);
788 result = kernel();
789 assert.equal(result.result.length, 2);
790 assert.equal(result.result1.length, 2);
791 assert.deepEqual(result.result.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]);
792 assert.deepEqual(result.result1.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]);
793 assert.deepEqual(Array.from(kernel.output), [2,2,2]);
794

Callers 1

dynamic-output.jsFile · 0.85

Calls 4

createKernelMapMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
setOutputMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…