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

Method constructor

tfjs-backend-webgl/src/slice_gpu.ts:28–51  ·  view source on GitHub ↗
(destSize: number[])

Source from the content-addressed store, hash-verified

26 customUniforms: Array<{name: string; arrayIndex: number; type: UniformType;}>;
27
28 constructor(destSize: number[]) {
29 this.outputShape = destSize;
30 this.rank = destSize.length;
31
32 const dtype = getCoordsDataType(this.rank);
33 this.customUniforms = [{name: 'start', arrayIndex: this.rank, type: 'int'}];
34 const sourceCoords = getCoords(this.rank);
35
36 let body: string;
37 const coordSum = destSize.map((_, i) => {
38 return `sourceLoc.${coords[i]} = start[${i}] + coords.${coords[i]};`;
39 });
40 body = `
41 ${dtype} sourceLoc;
42 ${dtype} coords = getOutputCoords();
43 ${coordSum.join('\n')}
44 `;
45 this.userCode = `
46 void main() {
47 ${body}
48 setOutput(getSource(${sourceCoords}));
49 }
50 `;
51 }
52}
53
54const coords = ['x', 'y', 'z', 'w', 'u', 'v'];

Callers

nothing calls this directly

Calls 3

getCoordsDataTypeFunction · 0.90
joinMethod · 0.80
getCoordsFunction · 0.70

Tested by

no test coverage detected