MCPcopy Index your code
hub / github.com/pytorch/tutorials / timed

Function timed

intermediate_source/torch_compile_full_example.py:68–75  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

66# in seconds. We use CUDA events and synchronization for the most accurate
67# measurements.
68def timed(fn):
69 start = torch.cuda.Event(enable_timing=True)
70 end = torch.cuda.Event(enable_timing=True)
71 start.record()
72 result = fn()
73 end.record()
74 torch.cuda.synchronize()
75 return result, start.elapsed_time(end) / 1000
76
77
78# Generates random input and targets data for the model, where `b` is

Callers 1

Calls 2

recordMethod · 0.80
fnFunction · 0.70

Tested by

no test coverage detected