File tree 1 file changed +20
-0
lines changed
userbenchmark/dynamo/dynamobench/_dynamo 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,26 @@ def bw_compiler(
312
312
)
313
313
314
314
315
+ class InductorAndRecordGraphs :
316
+ def __init__ (self ) -> None :
317
+ self .graphs : list [torch .fx .GraphModule ] = []
318
+ self .inductor_graphs : list [torch .fx .GraphModule ] = []
319
+
320
+ def __call__ (self , gm , example_inputs ): # type: ignore[no-untyped-def]
321
+ import torch ._inductor .compile_fx as compile_fx_mod
322
+
323
+ self .graphs .append (gm )
324
+
325
+ old_compile_fx_inner = compile_fx_mod ._compile_fx_inner
326
+
327
+ def patched (* args , ** kwargs ): # type: ignore[no-untyped-def]
328
+ self .inductor_graphs .append (args [0 ])
329
+ return old_compile_fx_inner (* args , ** kwargs )
330
+
331
+ with patch .object (compile_fx_mod , "_compile_fx_inner" , new = patched ):
332
+ return compile_fx_mod .compile_fx (gm , example_inputs )
333
+
334
+
315
335
def strip_comment (code : str ) -> str :
316
336
return re .sub (r"(?m)^ *#.*\n?" , "" , code )
317
337
You can’t perform that action at this time.
0 commit comments