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

Function constantsToString

src/backend/cpu/kernel-string.js:3–27  ·  view source on GitHub ↗
(constants, types)

Source from the content-addressed store, hash-verified

1const { utils } = require('../../utils');
2
3function constantsToString(constants, types) {
4 const results = [];
5 for (const name in types) {
6 if (!types.hasOwnProperty(name)) continue;
7 const type = types[name];
8 const constant = constants[name];
9 switch (type) {
10 case 'Number':
11 case 'Integer':
12 case 'Float':
13 case 'Boolean':
14 results.push(`${name}:${constant}`);
15 break;
16 case 'Array(2)':
17 case 'Array(3)':
18 case 'Array(4)':
19 case 'Matrix(2)':
20 case 'Matrix(3)':
21 case 'Matrix(4)':
22 results.push(`${name}:new ${constant.constructor.name}(${JSON.stringify(Array.from(constant))})`);
23 break;
24 }
25 }
26 return `{ ${ results.join() } }`;
27}
28
29function cpuKernelString(cpuKernel, name) {
30 const header = [];

Callers 1

cpuKernelStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…