@@ -181,30 +181,32 @@ def insert_nops(instructions: list[Any], code_options: Any) -> None:
181
181
instructions .insert (0 , create_instruction ("NOP" ))
182
182
instructions .insert (0 , create_instruction ("NOP" ))
183
183
184
- if is_generator (frame .f_code ):
185
- return None
186
-
187
- debug_checks (frame .f_code )
188
- code = transform_code_object (frame .f_code , insert_nops )
189
- graph = OutputGraph (
190
- code_options = {},
191
- compiler_fn = None ,
192
- root_tx = None ,
193
- export = False ,
194
- export_constraints = None ,
195
- frame_state = {"_id" : 0 },
196
- # TODO: shouldn't this be f_locals/f_globals from frame?
197
- local_scope = locals (),
198
- global_scope = globals (),
199
- f_code = frame .f_code ,
200
- torch_function_mode_stack = [],
201
- )
184
+ metrics_context = torch ._dynamo .utils .get_metrics_context ()
185
+ with torch ._dynamo .utils .dynamo_timed ("debug_insert_nops" ), metrics_context :
186
+ if is_generator (frame .f_code ):
187
+ return None
188
+
189
+ debug_checks (frame .f_code )
190
+ code = transform_code_object (frame .f_code , insert_nops )
191
+ graph = OutputGraph (
192
+ code_options = {},
193
+ compiler_fn = None ,
194
+ root_tx = None ,
195
+ export = False ,
196
+ export_constraints = None ,
197
+ frame_state = {"_id" : 0 },
198
+ # TODO: shouldn't this be f_locals/f_globals from frame?
199
+ local_scope = locals (),
200
+ global_scope = globals (),
201
+ f_code = frame .f_code ,
202
+ torch_function_mode_stack = [],
203
+ )
202
204
203
- return GuardedCode (
204
- code ,
205
- CheckFunctionManager (frame .f_code , graph ).guard_manager , # type: ignore[arg-type]
206
- CompileId (frame_id = 0 , frame_compile_id = 0 ),
207
- )
205
+ return GuardedCode (
206
+ code ,
207
+ CheckFunctionManager (frame .f_code , graph ).guard_manager , # type: ignore[arg-type]
208
+ CompileId (frame_id = 0 , frame_compile_id = 0 ),
209
+ )
208
210
209
211
210
212
class CompileCounter :
0 commit comments