MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / bench

Function bench

tests/profile_subclass/profiling.py:30–42  ·  view source on GitHub ↗
(t1, t2)

Source from the content-addressed store, hash-verified

28
29
30def 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
45def main():

Callers 1

mainFunction · 0.85

Calls 3

PerfContextClass · 0.90
addMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…