tvm.dlight
DLight package provides efficient schedules out-of-box for deep learning workloads.
- class tvm.dlight.ApplyDefaultSchedule(*rules: ScheduleRule)
A IRModule pass that applies a list of ScheduleRules to all PrimFuncs in the module.
- class tvm.dlight.BlockInfo(name: str, iters: List[IterInfo], block_rv: BlockRV, reduction_block: bool = False)
Information about a TIR block.
- class tvm.dlight.IterInfo(kind: typing_extensions.Literal[S, R, O], var: Var, dom: PrimExpr, loop_rv: LoopRV)
Information about a loop/iter var.
- class tvm.dlight.ScheduleRule
A thin wrapper on an arbitrary function that can be used to schedule a TIR PrimFunc.
Given a PrimFunc, a target, and a tunable flag, the apply method of a ScheduleRule returns either a Schedule, a list of Schedules, or None, where None means that the rule is not applicable to the given PrimFunc. If the tunable flag is True, the ScheduleRule is allowed to return either a Schedule or a list of Schedules, and the Schedules are allowed to contain tunable instructions. If the tunable flag is False, the ScheduleRule is only allowed to return a Schedule, and the Schedule is not allowed to contain tunable instructions.
- apply(func: PrimFunc, target: Target, tunable: bool) None | Schedule | List[Schedule]
Apply the ScheduleRule to the given PrimFunc.
- Parameters:
func (tir.PrimFunc) – The PrimFunc to apply the ScheduleRule to.
target (Target) – The compilation target the schedule is supposed to be built for.
tunable (bool) – Whether the schedule is allowed to contain tunable instructions.
- Returns:
results – Either a Schedule, a list of Schedules, or None, where None means that the rule is not applicable to the given PrimFunc.
- Return type:
Union[None, tir.Schedule, List[tir.Schedule]]
- static from_callable(name) Callable[[Callable[[PrimFunc, Target, bool], None | Schedule | List[Schedule]]], ScheduleRule]
Create a ScheduleRule from a callable.
- Parameters:
name (str)
- Returns:
decorator – A decorator that takes a callable and returns a ScheduleRule.
- Return type:
Callable
Examples
@ScheduleRule.from_callable("MyRule") def my_rule(func: tir.PrimFunc, target: Target, tunable: bool) -> Union[None, Schedule] # Do something with func and target
- tvm.dlight.normalize_prim_func(sch: Schedule) List[BlockInfo] | None
Normalize the primfunc to normal form
- tvm.dlight.try_inline(sch: Schedule, blocks: List[BlockInfo]) List[BlockInfo]
Try to inline as many blocks as possible, and return the remaining blocks.