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

Method disposeData

tfjs-backend-webgpu/src/backend_webgpu.ts:183–214  ·  view source on GitHub ↗

* Dispose the memory if the dataId has 0 refCount. Return true if the memory * is released or delayed in this backend, false if there are still * references. * @param dataId * @oaram force Optional, remove the data regardless of refCount

(dataId: DataId, force = false)

Source from the content-addressed store, hash-verified

181 * @oaram force Optional, remove the data regardless of refCount
182 */
183 override disposeData(dataId: DataId, force = false): boolean {
184 // No-op if already disposed.
185 if (!this.tensorMap.has(dataId)) {
186 return true;
187 }
188
189 const tensorData = this.tensorMap.get(dataId);
190 if (force) {
191 tensorData.refCount = 0;
192 } else {
193 tensorData.refCount--;
194 }
195
196 if (tensorData.refCount > 0) {
197 return false;
198 }
199
200 if (tensorData.complexTensorInfos != null) {
201 this.disposeData(tensorData.complexTensorInfos.real.dataId);
202 this.disposeData(tensorData.complexTensorInfos.imag.dataId);
203 }
204
205 if (this.commandQueueOwnedIds.has(dataId)) {
206 this.tensorDataPendingDisposal.push(dataId);
207 return true;
208 }
209
210 this.releaseResource(dataId);
211 this.tensorMap.delete(dataId);
212
213 return true;
214 }
215
216 override memory(): WebGPUMemoryInfo {
217 return {

Callers

nothing calls this directly

Calls 5

releaseResourceMethod · 0.95
hasMethod · 0.80
deleteMethod · 0.80
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected