(func, types, args, kwargs, result)
| 220 | MB = 1024 * 1024.0 |
| 221 | |
| 222 | def memory_hook(func, types, args, kwargs, result): |
| 223 | mem = torch.cuda.memory_allocated() / MB if torch.cuda.is_available() else 0.0 |
| 224 | peak = torch.cuda.max_memory_allocated() / MB if torch.cuda.is_available() else 0.0 |
| 225 | torch.cuda.reset_peak_memory_stats() if torch.cuda.is_available() else None |
| 226 | return {"mem": f"{mem:.3f} MB", "peak": f"{peak:.3f} MB"} |
| 227 | |
| 228 | with ( |
| 229 | DebugMode() as dm, |
nothing calls this directly
no outgoing calls
no test coverage detected