(func, inps, reps, unpack_inps, is_mge)
| 392 | |
| 393 | |
| 394 | def 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 | |
| 417 | def get_avg_time(func, inps, reps, unpack_inps, is_mge): |
no test coverage detected