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

Method profile

tfjs-core/src/engine.ts:976–998  ·  view source on GitHub ↗
(query: () => (TensorContainer | Promise<TensorContainer>))

Source from the content-addressed store, hash-verified

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;

Callers 5

timeMatmulFunction · 0.80
profileFunction · 0.80
engine_test.tsFile · 0.80
app.jsFile · 0.80
profileInferenceFunction · 0.80

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected