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

Method constructor

tfjs-backend-webgl/src/pack_gpu.ts:31–66  ·  view source on GitHub ↗
(
      outputShape:
          number[])

Source from the content-addressed store, hash-verified

29 rank: number;
30
31 constructor(
32 outputShape:
33 number[]) { // TODO(https://github.com/tensorflow/tfjs/issues/893):
34 // Only input / output 3D tensors.
35 this.outputShape = outputShape;
36 this.rank = outputShape.length;
37 this.enableShapeUniforms = useShapeUniforms(this.outputShape.length);
38
39 if (this.rank === 0) {
40 this.userCode = `
41 void main() {
42 setOutput(vec4(getA(), 0., 0., 0.));
43 }
44 `;
45 } else {
46 const channels = getChannels('rc', this.rank);
47 const dtype = getCoordsDataType(this.rank);
48 const outOfBoundsCondition = this.getOutOfBoundsCondition(channels);
49 const setup = this.getSetup(channels);
50 const output = this.getOutput(channels);
51
52 this.userCode = `
53 void main() {
54 ${dtype} rc = getOutputCoords();
55
56 if(${outOfBoundsCondition}) {
57 setOutput(vec4(0));
58 } else {
59 ${setup}
60
61 setOutput(vec4(${output}));
62 }
63 }
64 `;
65 }
66 }
67
68 private getSourceCoordsArr(dims: string[]): string[] {
69 const coords = [];

Callers

nothing calls this directly

Calls 6

getSetupMethod · 0.95
getOutputMethod · 0.95
useShapeUniformsFunction · 0.90
getChannelsFunction · 0.90
getCoordsDataTypeFunction · 0.90

Tested by

no test coverage detected