tvm_tirx.ir.transform.instrument#
Concrete tools for inspecting and timing IR transformations.
- class tvm_tirx.ir.transform.instrument.PassTimingInstrument#
Measure time spent in passes without changing their IR.
Install in
PassContext(instruments=[PassTimingInstrument()])and callrender()inside that context to read the accumulated profile.- static render()#
Retrieve the rendered pass timing profile.
- Returns:
string – The rendered string result of time profiles
- Return type:
string
Examples
timing_inst = PassTimingInstrument() with tvm_tirx.ir.transform.PassContext(instruments=[timing_inst]): mod = tvm_tirx.tirx.transform.StmtSimplify()(mod) # before exiting the context, get profile results. profiles = timing_inst.render()
- class tvm_tirx.ir.transform.instrument.PassPrintingInstrument(print_before_pass_names, print_after_pass_names)#
Print IR before and/or after passes selected by exact pass name.
- Parameters:
Examples
This observer leaves the IR unchanged:
observer = PassPrintingInstrument([], ["tirx.StmtSimplify"]) with tvm_tirx.ir.transform.PassContext(instruments=[observer]): after = tvm_tirx.tirx.transform.StmtSimplify()(mod)
- class tvm_tirx.ir.transform.instrument.PrintAfterAll(*args, **kwargs)#
Print pass metadata and output IR after every executed pass.
Use
PassContext(instruments=[PrintAfterAll()])to observe a pipeline. This instrument does not transform the module.
- class tvm_tirx.ir.transform.instrument.PrintBeforeAll(*args, **kwargs)#
Print pass metadata and input IR before every executed pass.
Use
PassContext(instruments=[PrintBeforeAll()])to observe a pipeline. This instrument does not transform the module.
- class tvm_tirx.ir.transform.instrument.DumpIR(dump_dir: Path | str, refresh: bool = False)#
Write each pass’s output TVMScript to a numbered file.
Files are named
000_<pass_name>.py,001_<pass_name>.py, and so on, with unsafe filename characters replaced by underscores. This instrument observes the module without changing it.- Parameters:
dump_dir (pathlib.Path or str) – Output directory, created when the first pass finishes.
refresh (bool) – If true, remove an existing directory only when all of its entries match the numbered dump-file pattern; otherwise preserve it.
Examples
with tvm_tirx.ir.transform.PassContext(instruments=[DumpIR("pass_ir")]): after = tvm_tirx.tirx.transform.StmtSimplify()(mod)