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

Method getUserCode

tfjs-backend-webgpu/src/slice_webgpu.ts:47–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 getUserCode(): string {
48 const dtype = getCoordsDataType(this.rank);
49 const sourceCoords = getCoords(this.rank);
50 let coordSum;
51 if (this.start.length === 1) {
52 coordSum = this.outputShape.map((_, i) => {
53 return `sourceLoc = uniforms.start + coords;`;
54 });
55 } else {
56 coordSum = this.outputShape.map((_, i) => {
57 return `sourceLoc.${coords[i]} = uniforms.start.${
58 getCoordsXYZ(i)} + coords.${coords[i]};`;
59 });
60 }
61
62 const userCode = `
63 ${main('index')} {
64 if (index < uniforms.size) {
65 var sourceLoc : ${dtype};
66 let coords = getCoordsFromIndex(index);
67 ${coordSum.join('\n')}
68 setOutputAtIndex(index, getSource(${sourceCoords}));
69 }
70 }
71 `;
72 return userCode;
73 }
74}
75
76const coords = ['x', 'y', 'z', 'w', 'u', 'v'];

Callers

nothing calls this directly

Calls 5

getCoordsDataTypeFunction · 0.90
getCoordsXYZFunction · 0.90
joinMethod · 0.80
getCoordsFunction · 0.70
mainFunction · 0.50

Tested by

no test coverage detected