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

Function benchmark

unstable_source/nestedtensor.py:315–321  ·  view source on GitHub ↗
(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

313######################################################################
314# Check correctness and performance
315def benchmark(func, *args, **kwargs):
316 torch.cuda.synchronize()
317 begin = timeit.default_timer()
318 output = func(*args, **kwargs)
319 torch.cuda.synchronize()
320 end = timeit.default_timer()
321 return output, (end - begin)
322
323output_nested, time_nested = benchmark(mha, query, key, value)
324output_padded, time_padded = benchmark(mha, padded_query, padded_key, padded_value)

Callers 1

nestedtensor.pyFile · 0.70

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected