MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / gpu_timeit

Method gpu_timeit

Utility/Timer.py:42–62  ·  view source on GitHub ↗
(cls, name: str)

Source from the content-addressed store, hash-verified

40
41 @classmethod
42 def gpu_timeit(cls, name: str):
43 def decorator(func):
44 @wraps(func)
45 def wrapped(*args, **kwargs):
46 if not cls.ACTIVE: return func(*args, **kwargs)
47 stream = torch.cuda.current_stream()
48 time_stream = cls.GPU_TIME_STREAM.get(name, ([], []))
49 start_event = torch.cuda.Event(enable_timing=True, blocking=False, interprocess=False)
50 end_event = torch.cuda.Event(enable_timing=True, blocking=False, interprocess=False)
51 time_stream[0].append(start_event)
52 time_stream[1].append(end_event)
53 cls.GPU_STREAMS.add(stream)
54 cls.GPU_TIME_STREAM[name] = time_stream
55
56 start_event.record(stream)
57 result = func(*args, **kwargs)
58 end_event.record(stream)
59
60 return result
61 return wrapped
62 return decorator
63
64 @classmethod
65 @contextmanager

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected