Expand description
fuse_generic — put back into one register window what legalization had to take apart.
★ THE POINT OF SPLITTING FIRST AND FUSING AFTER. A fused operator written by hand is a claim
nobody can check: it is one opaque kernel, and whether it computes the composition it is named
after is a matter of reading it carefully. Legalizing into stages and then fusing them makes the
same kernel a REWRITE — and a rewrite has a before and an after that equivalent_under
(spatial/equiv.rs) can evaluate against each other. The performance is identical; the
difference is that one of them is checkable.
What this fuses: two adjacent ComputeOp::Generic stages where the second consumes the first’s
only output, both walk the same fully-parallel iteration space, and the composition is one the
destination registers can carry — the outer operation’s second operand must be a plain tile,
because the broadcast instruction family (mul_tiles_bcast_cols and friends) reads two circular
buffers and has no dest-reuse spelling. Everything else is left alone rather than guessed at.
It runs at Phase::Template, before tile and place, so removing a stage costs only a dense
renumber of stages/buffers/edges — there is no placement, memory map or schedule to keep in step.
Functions§
- fuse_
generic - Fuse until nothing more qualifies.