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

[MetaSchedule] preseve global_symbol attached to function after applying MS #14219

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/tvm/meta_schedule/tune_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
def _normalize_mod(mod: Union[PrimFunc, IRModule]) -> IRModule:
"""Normalize the input to an IRModule"""
if isinstance(mod, PrimFunc):
mod = mod.with_attr("global_symbol", "main")
if not (mod.attrs and "global_symbol" in mod.attrs):
mod = mod.with_attr("global_symbol", "main")
mod = mod.with_attr("tir.noalias", True)
mod = IRModule({"main": mod})
Comment on lines +47 to 50
Copy link
Contributor

Choose a reason for hiding this comment

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

I’m not very sure here. One of the principle is that when a function in an IRModule has global_symbol, the global_symbol value and its global var name are supposed to equal. Here we are creating an IRModule with the only function “main”, so I think it is reasonable to attach global_symbol “main” to the function.

Copy link
Contributor Author

@jinhongyii jinhongyii Mar 7, 2023

Choose a reason for hiding this comment

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

Good thought! The inconsistency of global_symbol in the case I'm handling comes from the applying MS phase, so it seems I should change the code there

Copy link
Contributor Author

@jinhongyii jinhongyii Mar 7, 2023

Choose a reason for hiding this comment

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

btw, do we really have this principle? I read through the code and find many cases where it uses global var's name_hint and global_symbol for different branches. (such as internal linkage vs external linkage). Overwriting the func's global_symbol with main throw aways possible information we need
.

if not isinstance(mod, IRModule):
Expand Down