tvm.dlight#
DLight package provides efficient schedules out-of-box for deep learning workloads.
- class tvm.dlight.ApplyDefaultSchedule(*rules)[源代码]#
A IRModule pass that applies a list of ScheduleRules to all PrimFuncs in the module.
- 参数:
rules (ScheduleRule)
- __init__(*rules)[源代码]#
Construct a new ApplyDefaultSchedule pass.
Parameters#
- *rulesScheduleRule
The ScheduleRules to apply to all PrimFuncs in the module.
- 参数:
rules (ScheduleRule)
- class tvm.dlight.BlockInfo(name, iters, block_rv, reduction_block=False)[源代码]#
Information about a TIR block.
- is_elementwise(sch)[源代码]#
Whether the block is elementwise, i.e. trivial mapping between read/write region
- class tvm.dlight.IterInfo(kind, var, dom, loop_rv)[源代码]#
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, target, tunable)[源代码]#
Apply the ScheduleRule to the given PrimFunc.
Parameters#
- functir.PrimFunc
The PrimFunc to apply the ScheduleRule to.
- targetTarget
The compilation target the schedule is supposed to be built for.
- tunablebool
Whether the schedule is allowed to contain tunable instructions.
Returns#
- resultsUnion[None, tir.Schedule, List[tir.Schedule]]
Either a Schedule, a list of Schedules, or None, where None means that the rule is not applicable to the given PrimFunc.
- static from_callable(name)[源代码]#
Create a ScheduleRule from a callable.
Parameters#
name : str
Returns#
- decoratorCallable
A decorator that takes a callable and returns a ScheduleRule.
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.try_inline(sch, blocks)[源代码]#
Try to inline as many blocks as possible, and return the remaining blocks.
Parameters#
- schtir.Schedule
The TIR schedule used to inline blocks.
- blocksList[BlockInfo]
The blocks to be inlined.
Returns#
- remainingList[BlockInfo]
The remaining blocks that cannot be inlined.
- tvm.dlight.try_inline_contiguous_spatial(sch, block_infos)[源代码]#
Try to inline contiguous spatial blocks in a schedule
Parameters#
- schtir.Schedule
The TIR schedule used to inline blocks.
- block_infosList[BlockInfo]
The blocks to be try.
Returns#
- remainingList[BlockInfo]
The remaining blocks that cannot be inlined.