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

Method getUserCode

tfjs-backend-webgpu/src/rotate_webgpu.ts:55–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53 }
54
55 getUserCode(): string {
56 const userCode = `
57 ${main('index')} {
58 if (index < uniforms.size) {
59 let coords = getCoordsFromIndex(index);
60 let coordXFloat = (f32(coords[2]) - uniforms.centerX) *
61 uniforms.cosRadians - (f32(coords[1]) - uniforms.centerY) *
62 uniforms.sinRadians;
63 let coordYFloat = (f32(coords[2]) - uniforms.centerX) *
64 uniforms.sinRadians + (f32(coords[1]) - uniforms.centerY) *
65 uniforms.cosRadians;
66 let coordX = i32(round(coordXFloat + uniforms.centerX));
67 let coordY = i32(round(coordYFloat + uniforms.centerY));
68 ${this.fillSnippet}
69 if(coordX >= 0 && coordX < uniforms.xShape[2] && coordY >= 0 &&
70 coordY < uniforms.xShape[1]) {
71 outputValue = getX(coords[0], coordY, coordX, coords[3]);
72 }
73 setOutputAtIndex(index, outputValue);
74 }
75 }
76 `;
77 return userCode;
78 }
79}

Callers

nothing calls this directly

Calls 1

mainFunction · 0.50

Tested by

no test coverage detected