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

Function timed

intermediate_source/torch_compile_tutorial.py:159–166  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

157# in seconds. We use CUDA events and synchronization for the most accurate
158# measurements.
159def timed(fn):
160 start = torch.cuda.Event(enable_timing=True)
161 end = torch.cuda.Event(enable_timing=True)
162 start.record()
163 result = fn()
164 end.record()
165 torch.cuda.synchronize()
166 return result, start.elapsed_time(end) / 1000
167
168
169inp = torch.randn(4096, 4096).cuda()

Callers 1

Calls 2

recordMethod · 0.80
fnFunction · 0.70

Tested by

no test coverage detected