Skip to main content

Module fusion

Module fusion 

Source
Expand description

Operator fusion pass — merges chains of fusible element-wise kernels.

§What is fused

Two consecutive kernel nodes a → b are fusion candidates when:

  1. Both are marked fusible in their NodeKind::KernelLaunch.
  2. a dominates b in the dominator tree (no side path can bypass b).
  3. There is no non-fusible node on any path from a to b.
  4. a has exactly one output buffer shared with b’s inputs (single producer–consumer chain — avoids creating broadcast copies).
  5. Both have the same launch configuration (same total thread count), or b uses a configuration that is a submultiple of a’s grid.

When a group is fusible, the pass produces a FusionGroup describing which original nodes should be merged. The graph itself is not modified by this pass — the Executor is responsible for lowering the fusion groups into combined PTX.

§Algorithm

  1. Run topological analysis to get ASAP order and level info.
  2. Run dominance analysis.
  3. Traverse nodes in topological order; greedily extend chains of fusible nodes that satisfy the rules above.
  4. Return the list of FusionGroups.

Structs§

FusionGroup
A group of nodes that can be merged into a single fused kernel.
FusionPlan
The complete fusion plan produced by the fusion pass.

Functions§

analyse
Runs the fusion analysis pass on graph.