tvm_tirx.ir.transform.PassContext#
- class tvm_tirx.ir.transform.PassContext(opt_level=2, required_pass=None, disabled_pass=None, instruments=None, config=None)#
Bases:
ObjectScope optimization levels, pass selection, instruments, and pass options.
Use a
PassContextas awithblock. Every pass that runs inside the block, called directly or by aSequential, sees this context asPassContext.current()and receives it as thectxargument of its callback. Outside anywithblock, a default context withopt_level=2and no other options is active.- Parameters:
opt_level (Optional[int]) – Maximum optimization level enabled in sequential pipelines (default 2). A
Sequentialskips a child pass whoseinfo.opt_levelis higher. Calling a pass directly ignores this level.required_pass (Optional[Union[List[str], Set[str], Tuple[str]]]) – Pass names to enable regardless of their optimization level.
disabled_pass (Optional[Union[List[str], Set[str], Tuple[str]]]) – Pass names to skip in sequential pipelines, even if required.
instruments (Optional[Sequence[PassInstrument]]) – The list of pass instrument implementations. They observe every pass that runs inside the context.
config (Optional[Dict[str, Object]]) – Additional configurations for specific passes. Keys must be registered option names, which
list_configs()lists; an unknown key raises an error.
Examples
from tvm_tirx import tirx from tvm_tirx.ir.transform import PassContext, Sequential pipeline = Sequential([tirx.transform.StmtSimplify(), my_pass]) with PassContext(opt_level=3, disabled_pass=["tirx.StmtSimplify"]): assert PassContext.current().opt_level == 3 after = pipeline(mod) # runs only my_pass
- override_instruments(instruments)#
Override instruments within this PassContext.
If there are existing instruments, their
exit_pass_ctxcallbacks are called. Then switching to new instruments and calling newenter_pass_ctxcallbacks.- instrumentsSequence[PassInstrument]
The list of pass instrument implementations.
- static current()#
Return the current pass context.
- static list_configs()#
List all registered PassContext configuration names and metadata.
- Returns:
configs (Dict[str, Dict[str, str]])
- property config#
- property disabled_pass#
- property instruments#
- property opt_level#
- property required_pass#