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

Method trackTensor

tfjs-core/src/engine.ts:872–898  ·  view source on GitHub ↗
(a: Tensor, backend: KernelBackend)

Source from the content-addressed store, hash-verified

870 }
871
872 trackTensor(a: Tensor, backend: KernelBackend): void {
873 this.state.numTensors++;
874 if (a.dtype === 'string') {
875 this.state.numStringTensors++;
876 }
877 // Bytes for complex numbers are counted by their components. Bytes for
878 // string tensors are counted when writing values.
879 let bytes = 0;
880 if (a.dtype !== 'complex64' && a.dtype !== 'string') {
881 bytes = a.size * util.bytesPerElement(a.dtype);
882 }
883 this.state.numBytes += bytes;
884
885 if (!this.state.tensorInfo.has(a.dataId)) {
886 this.state.numDataBuffers++;
887 this.state.tensorInfo.set(a.dataId, {
888 backend: backend || this.backend,
889 dtype: a.dtype,
890 shape: a.shape,
891 bytes
892 });
893 }
894
895 if (!(a instanceof Variable)) {
896 this.track(a);
897 }
898 }
899
900 // Track the tensor by dataId and increase the refCount for the dataId in the
901 // backend.

Callers 3

makeTensorMethod · 0.95
incRefMethod · 0.95

Calls 3

trackMethod · 0.95
hasMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected