MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / timer_record

Function timer_record

wan/utils/utils.py:389–413  ·  view source on GitHub ↗
(model_name="")

Source from the content-addressed store, hash-verified

387 return wrapper
388
389def timer_record(model_name=""):
390 def decorator(func):
391 def wrapper(*args, **kwargs):
392 torch.cuda.synchronize()
393 start_time = time.time()
394 result = func(*args, **kwargs)
395 torch.cuda.synchronize()
396 end_time = time.time()
397 import torch.distributed as dist
398 if dist.is_initialized():
399 if dist.get_rank() == 0:
400 time_sum = end_time - start_time
401 print('# --------------------------------------------------------- #')
402 print(f'# {model_name} time: {time_sum}s')
403 print('# --------------------------------------------------------- #')
404 _write_to_excel(model_name, time_sum)
405 else:
406 time_sum = end_time - start_time
407 print('# --------------------------------------------------------- #')
408 print(f'# {model_name} time: {time_sum}s')
409 print('# --------------------------------------------------------- #')
410 _write_to_excel(model_name, time_sum)
411 return result
412 return wrapper
413 return decorator
414
415def _write_to_excel(model_name, time_sum):
416 import os

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected