(t1, t2)
| 28 | |
| 29 | |
| 30 | def bench(t1, t2): |
| 31 | bench_times = [] |
| 32 | for _ in range(NUM_REPEAT_OF_REPEATS): |
| 33 | with PerfContext() as pc: |
| 34 | for _ in range(NUM_REPEATS): |
| 35 | torch.add(t1, t2) |
| 36 | bench_times.append(pc.total_time) |
| 37 | |
| 38 | bench_time_min = float(torch.min(torch.Tensor(bench_times))) / NUM_REPEATS |
| 39 | bench_time_avg = float(torch.sum(torch.Tensor(bench_times))) / (NUM_REPEATS * NUM_REPEAT_OF_REPEATS) |
| 40 | bench_time_med = float(torch.median(torch.Tensor(bench_times))) / NUM_REPEATS |
| 41 | bench_std = float(torch.std(torch.Tensor(bench_times))) / NUM_REPEATS |
| 42 | return bench_time_min, bench_time_avg, bench_time_med, bench_std |
| 43 | |
| 44 | |
| 45 | def main(): |
no test coverage detected
searching dependent graphs…