[Transform] Preserve all reachable functions in FuseTIR#16471
[Transform] Preserve all reachable functions in FuseTIR#16471Lunderberg wants to merge 1 commit intoapache:mainfrom
Conversation
|
@slyubomirsky Would this resolve the problem encountered in #16462 ? I think this would avoid throwing out the in-place updates, and would also allow handling of context-dependent fusions, depending on whether the call site could support an in-place operation. |
Prior to this commit, the `FuseTIR` pass had custom logic to determine whether a `PrimFunc` should be kept in the output `IRModule`. This commit replaces this check in `FuseTIR` with a post-processing by `DeadCodeElimination`.
33c3d6a to
de8b8b6
Compare
|
|
| return call; | ||
| } | ||
|
|
||
| tir::PrimFunc fused_tir = FusedTIRConstructor::GetFusedTIR(orig_mod_, old_gvar); |
There was a problem hiding this comment.
Are you sure we aren't likely to call this more than once per global var? As long as it's not likely or costly, this approach is probably fine.
There was a problem hiding this comment.
It probably would be called several times. The fused Relax function is generated once per pattern match in FuseOpsByPattern, and is then de-duplicated, leaving many calls to a single kPrimitive function. This would generate the fused TIR function once per callsite, after which the resulting functions would be de-duplicated. Whether that is good or bad would probably depend on the usefulness for call_tir_inplace, so I'll take a look at #16487.
There was a problem hiding this comment.
Oh so there's probably no issue with calling it more often than in the current way the pass is written. That seems good to me.
|
See 16487, the in-place case will be handled. |
Sounds good. I think I still like having this change overall, as it avoids having duplicate logic for DCE. When 16487, I'll rebase this PR on top of it. |
Prior to this commit, the
FuseTIRpass had custom logic to determine whether aPrimFuncshould be kept in the outputIRModule. This commit replaces this check inFuseTIRwith a post-processing byDeadCodeElimination.