-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Transform] Preserve all reachable functions in FuseTIR #16471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Transform] Preserve all reachable functions in FuseTIR #16471
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.