MCPcopy
hub / github.com/gpujs/gpu.js / inputZYXVariables

Function inputZYXVariables

test/features/input.js:240–256  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

238
239
240function inputZYXVariables(mode) {
241 const gpu = new GPU({ mode });
242 const kernel = gpu.createKernel(function(a, x, y, z) {
243 return a[z][y][x];
244 })
245 .setOutput([1]);
246
247 const a = new Float32Array(32);
248 a.set([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]);
249 const aInput = input(a, [2, 4, 4]);
250 assert.deepEqual(Array.from(kernel(aInput, 1, 2, 3)), [30]);
251 assert.deepEqual(Array.from(kernel(aInput, 0, 2, 3)), [29]);
252 assert.deepEqual(Array.from(kernel(aInput, 0, 2, 1)), [13]);
253 assert.deepEqual(Array.from(kernel(aInput, 1, 2, 2)), [22]);
254 assert.deepEqual(Array.from(kernel(aInput, 0, 2, 2)), [21]);
255 gpu.destroy();
256}
257
258test("inputZYXVariables auto", () => {
259 inputZYXVariables();

Callers 1

input.jsFile · 0.85

Calls 5

createKernelMethod · 0.95
destroyMethod · 0.95
inputFunction · 0.85
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…