MCPcopy
hub / github.com/tensorflow/tfjs / constructor

Method constructor

tfjs-backend-webgl/src/backend_webgl.ts:144–173  ·  view source on GitHub ↗
(gpuResource?: GPGPUContext|HTMLCanvasElement|OffscreenCanvas)

Source from the content-addressed store, hash-verified

142 private warnedAboutMemory = false;
143
144 constructor(gpuResource?: GPGPUContext|HTMLCanvasElement|OffscreenCanvas) {
145 super();
146 if (!env().getBool('HAS_WEBGL')) {
147 throw new Error('WebGL is not supported on this device');
148 }
149
150 let newGPGPU;
151 if (gpuResource != null) {
152 if (gpuResource instanceof GPGPUContext) {
153 newGPGPU = gpuResource;
154 } else {
155 const gl =
156 getWebGLContext(env().getNumber('WEBGL_VERSION'), gpuResource);
157 newGPGPU = new GPGPUContext(gl);
158 }
159 this.binaryCache = {};
160 this.gpgpuCreatedLocally = false;
161 } else {
162 const gl = getWebGLContext(env().getNumber('WEBGL_VERSION'));
163 newGPGPU = new GPGPUContext(gl);
164 this.binaryCache = getBinaryCache(env().getNumber('WEBGL_VERSION'));
165 this.gpgpuCreatedLocally = true;
166 }
167
168 this.gpgpu = newGPGPU;
169 this.canvas = this.gpgpu.gl.canvas;
170 this.textureManager = new TextureManager(this.gpgpu);
171 this.numMBBeforeWarning = numMBBeforeWarning();
172 this.texData = new DataStorage(this, engine());
173 }
174
175 override numDataIds() {
176 return this.texData.numDataIds() - this.pendingDeletes;

Callers

nothing calls this directly

Calls 7

envFunction · 0.90
getWebGLContextFunction · 0.90
engineFunction · 0.90
getBinaryCacheFunction · 0.85
numMBBeforeWarningFunction · 0.85
getBoolMethod · 0.80
getNumberMethod · 0.80

Tested by

no test coverage detected