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

Method constructor

tfjs-backend-webgl/src/select_gpu.ts:26–65  ·  view source on GitHub ↗
(cRank: number, shape: number[], rank: number)

Source from the content-addressed store, hash-verified

24 userCode: string;
25
26 constructor(cRank: number, shape: number[], rank: number) {
27 this.outputShape = shape;
28
29 let cCoords;
30 let abCoords;
31 if (rank > 4) {
32 throw Error(`Where for rank ${rank} is not yet supported`);
33 }
34
35 if (rank === 1) {
36 abCoords = `resRC`;
37 cCoords = `resRC`;
38 } else {
39 const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w'];
40 const cCoordVars = [];
41 const abCoordVars = [];
42 for (let i = 0; i < shape.length; i++) {
43 abCoordVars.push(`${currentCoords[i]}`);
44 if (i < cRank) {
45 cCoordVars.push(`${currentCoords[i]}`);
46 }
47 }
48 cCoords = cCoordVars.join();
49 abCoords = abCoordVars.join();
50 }
51
52 const dtype = getCoordsDataType(rank);
53
54 this.userCode = `
55 void main() {
56 ${dtype} resRC = getOutputCoords();
57 float cVal = getC(${cCoords});
58 if (cVal >= 1.0) {
59 setOutput(getA(${abCoords}));
60 } else {
61 setOutput(getB(${abCoords}));
62 }
63 }
64 `;
65 }
66}

Callers

nothing calls this directly

Calls 4

getCoordsDataTypeFunction · 0.90
ErrorFunction · 0.85
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected