MCPcopy Create free account
hub / github.com/tensorflow/tfjs / constructor

Method constructor

tfjs-backend-webgl/src/addn_gpu.ts:25–50  ·  view source on GitHub ↗
(outputShape: number[], shapes: number[][])

Source from the content-addressed store, hash-verified

23 userCode: string;
24
25 constructor(outputShape: number[], shapes: number[][]) {
26 this.outputShape = outputShape;
27 this.variableNames = shapes.map((_, i) => `T${i}`);
28
29 const snippets: string[] = [];
30 // Get target elements from every input tensor.
31 this.variableNames.forEach(variable => {
32 snippets.push(`float v${variable} = get${variable}AtOutCoords();`);
33 });
34
35 // Calculate the sum of all elements.
36 const operation = this.variableNames
37 .map(variable => {
38 return `v${variable}`;
39 })
40 .join(' + ');
41
42 this.userCode = `
43 void main() {
44 ${snippets.join('\n ')}
45
46 float result = ${operation};
47 setOutput(result);
48 }
49 `;
50 }
51}

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected