MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / __exit__

Method __exit__

lightx2v/utils/profiler.py:74–88  ·  view source on GitHub ↗
(self, exc_type, exc_val, exc_tb)

Source from the content-addressed store, hash-verified

72 self.profile_memory = profile_memory
73
74 def _record_memory_peak(self, peak_allocated, peak_reserved):
75 self.peak_memory_allocated = max(self.peak_memory_allocated, peak_allocated)
76 if peak_reserved is not None:
77 self.peak_memory_reserved = max(self.peak_memory_reserved or 0, peak_reserved)
78
79 def _read_memory_peak(self):
80 peak_allocated = torch_device_module.max_memory_allocated()
81 max_memory_reserved = getattr(torch_device_module, "max_memory_reserved", None)
82 peak_reserved = max_memory_reserved() if max_memory_reserved is not None else None
83 return peak_allocated, peak_reserved
84
85 def _begin_memory_profile(self):
86 stack = _get_memory_profile_stack()
87 self._memory_profile_active = False
88 if not self.profile_memory:
89 return
90
91 reset_peak_memory_stats = getattr(torch_device_module, "reset_peak_memory_stats", None)

Callers

nothing calls this directly

Calls 3

_get_excluded_time_stackFunction · 0.85
popMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected