(query: () => (TensorContainer | Promise<TensorContainer>))
| 974 | } |
| 975 | |
| 976 | async profile(query: () => (TensorContainer | Promise<TensorContainer>)): |
| 977 | Promise<ProfileInfo> { |
| 978 | this.state.profiling = true; |
| 979 | |
| 980 | const startBytes = this.state.numBytes; |
| 981 | const startNumTensors = this.state.numTensors; |
| 982 | |
| 983 | this.state.activeProfile.kernels = []; |
| 984 | this.state.activeProfile.result = await query(); |
| 985 | |
| 986 | this.state.profiling = false; |
| 987 | |
| 988 | this.state.activeProfile.peakBytes = Math.max( |
| 989 | ...this.state.activeProfile.kernels.map(d => d.totalBytesSnapshot)); |
| 990 | this.state.activeProfile.newBytes = this.state.numBytes - startBytes; |
| 991 | this.state.activeProfile.newTensors = |
| 992 | this.state.numTensors - startNumTensors; |
| 993 | for (const kernel of this.state.activeProfile.kernels) { |
| 994 | kernel.kernelTimeMs = await kernel.kernelTimeMs; |
| 995 | kernel.extraInfo = await kernel.extraInfo; |
| 996 | } |
| 997 | return this.state.activeProfile; |
| 998 | } |
| 999 | |
| 1000 | isTapeOn(): boolean { |
| 1001 | return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; |
no test coverage detected