File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
benchmarks/dynamo/pr_time_benchmarks/benchmarks Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+
3
+ from benchmark_base import BenchmarkBase
4
+
5
+ import torch
6
+ from torch ._inductor .utils import fresh_inductor_cache
7
+
8
+
9
+ class Benchmark (BenchmarkBase ):
10
+ def __init__ (self ):
11
+ super ().__init__ (
12
+ category = "float_args" ,
13
+ backend = "inductor" ,
14
+ device = "cpu" ,
15
+ )
16
+
17
+ def name (self ):
18
+ return f"{ self .category ()} "
19
+
20
+ def description (self ):
21
+ return "Benchmark to measure recompilations with float arguments."
22
+
23
+ def _prepare_once (self ):
24
+ torch .manual_seed (0 )
25
+
26
+ def _prepare (self ):
27
+ torch ._dynamo .reset ()
28
+
29
+ def _work (self ):
30
+ @torch .compile (backend = "inductor" )
31
+ def f (x , y ):
32
+ return x + y
33
+
34
+ with fresh_inductor_cache ():
35
+ for i in range (8 ):
36
+ f (torch .arange (3 ), i * 2.5 )
37
+
38
+
39
+ def main ():
40
+ result_path = sys .argv [1 ]
41
+ Benchmark ().enable_compile_time_instruction_count ().collect_all ().append_results (
42
+ result_path
43
+ )
44
+
45
+
46
+ if __name__ == "__main__" :
47
+ main ()
You can’t perform that action at this time.
0 commit comments