MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / perf_func

Function perf_func

imperative/python/megengine/tools/benchmark_op.py:394–414  ·  view source on GitHub ↗
(func, inps, reps, unpack_inps, is_mge)

Source from the content-addressed store, hash-verified

392
393
394def perf_func(func, inps, reps, unpack_inps, is_mge):
395 if is_mge:
396 mge._full_sync()
397 tik = time.time()
398 for _ in range(reps):
399 if unpack_inps:
400 out = func(*inps)
401 else:
402 out = func(inps)
403 mge._full_sync()
404 else:
405 torch.cuda.synchronize()
406 with torch.no_grad():
407 tik = time.time()
408 for _ in range(reps):
409 if unpack_inps:
410 out = func(*inps)
411 else:
412 out = func(inps)
413 torch.cuda.synchronize()
414 return time.time() - tik
415
416
417def get_avg_time(func, inps, reps, unpack_inps, is_mge):

Callers 1

get_avg_timeFunction · 0.85

Calls 2

funcFunction · 0.70
synchronizeMethod · 0.45

Tested by

no test coverage detected