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

Function dispose

tfjs-layers/src/engine/container.ts:517–534  ·  view source on GitHub ↗

* Attempt to dispose a LayersModel's weights. * * This method decrease the reference count of the LayersModel object by 1. * * A LayersModel is reference-counted. Its reference count is incremented by 1 * when it is first constructed and when it is used as a Layer of another * Laye

()

Source from the content-addressed store, hash-verified

515 * already been disposed.
516 */
517 override dispose(): DisposeResult {
518 this.assertNotDisposed();
519 const result:
520 DisposeResult = {refCountAfterDispose: null, numDisposedVariables: 0};
521 if (--this._refCount === 0) {
522 for (const layer of this.layers) {
523 result.numDisposedVariables += layer.dispose().numDisposedVariables;
524 }
525
526 // Call dispose on each internally created container layer again to ensure
527 // their refCounts hit zero and their tensors are subsequently deleted.
528 for (const container of this.internalContainerRefs) {
529 result.numDisposedVariables += container.dispose().numDisposedVariables;
530 }
531 }
532 result.refCountAfterDispose = this._refCount;
533 return result;
534 }
535
536 override get trainable() {
537 return this.trainable_;

Callers

nothing calls this directly

Calls 2

assertNotDisposedMethod · 0.80
disposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…