MCPcopy Index your code
hub / github.com/tensorflow/tfjs / disposeTensor

Method disposeTensor

tfjs-core/src/engine.ts:917–943  ·  view source on GitHub ↗
(a: Tensor)

Source from the content-addressed store, hash-verified

915 }
916 }
917 disposeTensor(a: Tensor): void {
918 if (!this.state.tensorInfo.has(a.dataId)) {
919 return;
920 }
921 const info = this.state.tensorInfo.get(a.dataId);
922
923 this.state.numTensors--;
924 if (a.dtype === 'string') {
925 this.state.numStringTensors--;
926 this.state.numBytes -= info.bytes;
927 }
928 // Don't count bytes for complex numbers as they are counted by their
929 // components.
930 if (a.dtype !== 'complex64' && a.dtype !== 'string') {
931 const bytes = a.size * util.bytesPerElement(a.dtype);
932 this.state.numBytes -= bytes;
933 }
934
935 // Remove the reference to dataId if backend dispose the data successfully
936 if (info.backend.disposeData(a.dataId)) {
937 this.removeDataId(a.dataId, info.backend);
938 }
939
940 // TODO(nsthorat): Construct an error and save the stack trace for
941 // debugging when in debug mode. Creating a stack trace is too expensive
942 // to do unconditionally.
943 }
944
945 disposeVariables(): void {
946 for (const varName in this.state.registeredVariables) {

Callers 1

disposeVariableMethod · 0.95

Calls 4

removeDataIdMethod · 0.95
hasMethod · 0.80
disposeDataMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected