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

Method getUserCode

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

Source from the content-addressed store, hash-verified

45 }
46
47 getUserCode(): string {
48 const dtype = getCoordsDataType(this.outputShape.length);
49 const switched = getSwitchedCoords(this.newDim);
50
51 const userCode = `
52 ${main('index')} {
53 for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
54 let flatIndex = index * ${this.workPerThread} + i;
55 if(flatIndex < uniforms.size) {
56 let coords = getCoordsFromIndex(flatIndex);
57 setOutputAtIndex(flatIndex, A[getIndexFromCoords${
58 this.outputShape.length}D(
59 ${dtype}(${switched}), uniforms.aShape)]);
60 }
61 }
62 }
63 `;
64 return userCode;
65 }
66}
67
68export function getSwitchedCoords(newDim: number[]): string {

Callers

nothing calls this directly

Calls 3

getCoordsDataTypeFunction · 0.90
getSwitchedCoordsFunction · 0.70
mainFunction · 0.50

Tested by

no test coverage detected