Skip to content
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

[Unity][Transform] Keep R.ExternFunc in dead-code elimination #16118

Merged

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, the DeadCodeElimination and FuseTIR passes treated R.ExternFunc differently with respect to removal of internal functions: DeadCodeElimination treated these functions as internal, to be removed if there are no internal callers, while FuseTIR treated these functions as external, to be retained in all cases.

Because the visibility of a function is determined by the tvm::attr::kGlobalSymbol attribute; which is present for PrimFunc and relax::Function, but missing for relax::ExternFunc; there is no information in the IRModule that can determine whether a relax::ExternFunc should be visible externally.

For consistency, and to allow the use of DeadCodeElimination in future refactors of FuseTIR, this commit updates DeadCodeElimination to retain instances of relax::ExternFunc.

Prior to this commit, the `DeadCodeElimination` and `FuseTIR` passes
treated `R.ExternFunc` differently with respect to removal of internal
functions: `DeadCodeElimination` treated these functions as internal,
to be removed if there are no internal callers, while `FuseTIR`
treated these functions as external, to be retained in all cases.

Because the visibility of a function is determined by the
`tvm::attr::kGlobalSymbol` attribute; which is present for `PrimFunc`
and `relax::Function`, but missing for `relax::ExternFunc`; there is
no information in the `IRModule` that can determine whether a
`relax::ExternFunc` should be visible externally.

For consistency, and to allow the use of `DeadCodeElimination` in
future refactors of `FuseTIR`, this commit updates
`DeadCodeElimination` to retain instances of `relax::ExternFunc`.
Copy link
Contributor

@quic-sanirudh quic-sanirudh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@quic-sanirudh quic-sanirudh merged commit e7c7314 into apache:unity Nov 14, 2023
15 checks passed
@Lunderberg Lunderberg deleted the unity_transform_keep_extern_func_in_dce branch November 14, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants