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

Method constructor

tfjs-backend-webgpu/src/backend_webgpu.ts:136–170  ·  view source on GitHub ↗
(device: GPUDevice, adapterInfo?: GPUAdapterInfo)

Source from the content-addressed store, hash-verified

134 }
135
136 constructor(device: GPUDevice, adapterInfo?: GPUAdapterInfo) {
137 super();
138 if (!webgpu_util.isWebGPUSupported()) {
139 throw new Error('WebGPU is not supported on this device');
140 }
141 this.pipelineCache = {};
142 this.device = device;
143 this.queue = device.queue;
144 this.commandEncoder = null;
145 this.computePassEncoder = null;
146 this.adapterInfo = new AdapterInfo(adapterInfo);
147 this.supportTimestampQuery = this.device.features.has('timestamp-query');
148 this.thresholdToIncreaseWorkgroups =
149 this.adapterInfo.intelGPUGeneration >= 12 ? 16 : 8;
150
151 this.bufferManager = new BufferManager(this.device);
152 this.textureManager = new TextureManager(this.device);
153 this.tensorMap = new DataStorage(this, engine());
154
155 // Profiling tools like PIX needs this dummy canvas to
156 // trigger capturing a frame.
157 if (env().getBool('WEBGPU_USE_PROFILE_TOOL')) {
158 this.dummyCanvas = document.createElement('canvas');
159 this.dummyCanvas.width = 1;
160 this.dummyCanvas.height = 1;
161
162 this.dummyContext = this.dummyCanvas.getContext('webgpu');
163 this.dummyContext.configure({
164 device,
165 format: 'bgra8unorm',
166 });
167
168 document.body.appendChild(this.dummyCanvas);
169 }
170 }
171
172 override floatPrecision(): 32 {
173 return 32;

Callers

nothing calls this directly

Calls 5

engineFunction · 0.90
envFunction · 0.90
hasMethod · 0.80
getBoolMethod · 0.80
getContextMethod · 0.45

Tested by

no test coverage detected