(a: Tensor, backend: KernelBackend)
| 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. |
no test coverage detected