MCPcopy Create free account
hub / github.com/pytorch/tutorials / benchmark

Function benchmark

intermediate_source/transformer_building_blocks.py:357–364  ·  view source on GitHub ↗
(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

355
356
357def benchmark(func, *args, **kwargs):
358 torch.cuda.synchronize()
359 torch.cuda.reset_peak_memory_stats()
360 begin = timeit.default_timer()
361 output = func(*args, **kwargs)
362 torch.cuda.synchronize()
363 end = timeit.default_timer()
364 return output, (end - begin), torch.cuda.max_memory_allocated()
365
366
367##############################################################################

Callers 1

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected