(mode)
| 1152 | }); |
| 1153 | |
| 1154 | function testUnsignedPrecisionInputMatrix(mode) { |
| 1155 | const gpu = new GPU({ mode }); |
| 1156 | const kernel = gpu.createKernel(function(input) { |
| 1157 | return input[this.thread.y][this.thread.x]; |
| 1158 | }) |
| 1159 | .setPrecision('unsigned') |
| 1160 | .setDynamicArguments(true) |
| 1161 | .setDynamicOutput(true) |
| 1162 | .setOutput([4,4]); |
| 1163 | |
| 1164 | let matrix = input([ |
| 1165 | 1,2,3,4, |
| 1166 | 5,6,7,8, |
| 1167 | 9,10,11,12, |
| 1168 | 13,14,15,16 |
| 1169 | ], [4, 4]); |
| 1170 | assert.deepEqual(kernel(matrix), [ |
| 1171 | new Float32Array([1,2,3,4]), |
| 1172 | new Float32Array([5,6,7,8]), |
| 1173 | new Float32Array([9,10,11,12]), |
| 1174 | new Float32Array([13,14,15,16]), |
| 1175 | ]); |
| 1176 | |
| 1177 | kernel.setOutput([3,3]); |
| 1178 | matrix = input([ |
| 1179 | 1,2,3, |
| 1180 | 4,5,6, |
| 1181 | 7,8,9 |
| 1182 | ], [3,3]); |
| 1183 | assert.deepEqual(kernel(matrix), [ |
| 1184 | new Float32Array([1,2,3]), |
| 1185 | new Float32Array([4,5,6]), |
| 1186 | new Float32Array([7,8,9]) |
| 1187 | ]); |
| 1188 | |
| 1189 | kernel.setOutput([2,2]); |
| 1190 | matrix = input([ |
| 1191 | 1,2, |
| 1192 | 3,4 |
| 1193 | ], [2,2]); |
| 1194 | assert.deepEqual(kernel(matrix), [ |
| 1195 | new Float32Array([1,2]), |
| 1196 | new Float32Array([3,4]) |
| 1197 | ]); |
| 1198 | gpu.destroy(); |
| 1199 | } |
| 1200 | |
| 1201 | test('unsigned precision Input Matrix auto', () => { |
| 1202 | testUnsignedPrecisionInputMatrix(); |
no test coverage detected
searching dependent graphs…