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

Method constructor

tfjs-backend-webgl/src/complex_abs_gpu.ts:25–41  ·  view source on GitHub ↗
(shape: number[])

Source from the content-addressed store, hash-verified

23 outputShape: number[];
24
25 constructor(shape: number[]) {
26 this.outputShape = shape;
27 this.userCode = `
28 void main() {
29 float re = abs(getRealAtOutCoords());
30 float im = abs(getImagAtOutCoords());
31 float mx = max(re, im);
32
33 // sadly the length function in glsl is not underflow-safe
34 // (at least not on Intel GPUs). So the safe solution is
35 // to ensure underflow-safety in all cases.
36 setOutput(
37 mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))
38 );
39 }
40 `;
41 }
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected