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

Method constructor

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected