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

Function timed

recipes_source/torch_compiler_set_stance_tutorial.py:183–190  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

181# in seconds. We use CUDA events and synchronization for the most accurate
182# measurements.
183def timed(fn):
184 start = torch.cuda.Event(enable_timing=True)
185 end = torch.cuda.Event(enable_timing=True)
186 start.record()
187 result = fn()
188 end.record()
189 torch.cuda.synchronize()
190 return result, start.elapsed_time(end) / 1000
191
192
193@torch.compile

Calls 2

recordMethod · 0.80
fnFunction · 0.70

Tested by

no test coverage detected