Skip to content

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
@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.

2 participants