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

Method disposeData

tfjs-node/src/nodejs_kernel_backend.ts:240–255  ·  view source on GitHub ↗

* Dispose the memory if the dataId has 0 refCount. Return true if the memory * is released, false otherwise. * @param dataId * @oaram force Optional, remove the data regardless of refCount

(dataId: DataId, force = false)

Source from the content-addressed store, hash-verified

238 * @oaram force Optional, remove the data regardless of refCount
239 */
240 disposeData(dataId: DataId, force = false): boolean {
241 // No-op if already disposed.
242 if (this.tensorMap.has(dataId)) {
243 const id = this.tensorMap.get(dataId).id;
244 this.tensorMap.get(dataId).refCount--;
245 if (!force && this.tensorMap.get(dataId).refCount > 0) {
246 return false;
247 }
248
249 if (id != null && id >= 0) {
250 this.binding.deleteTensor(id);
251 }
252 this.tensorMap.delete(dataId);
253 }
254 return true;
255 }
256 /** Return refCount of a `TensorData`. */
257 refCount(dataId: DataId): number {
258 if (this.tensorMap.has(dataId)) {

Callers

nothing calls this directly

Calls 4

hasMethod · 0.80
deleteTensorMethod · 0.80
deleteMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected