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

[TIR] Update SplitHostDevice to post-process with ConvertSSA #14496

Merged
merged 2 commits into from
Apr 8, 2023

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, the same tir::Var could be defined both in the body of the host function and in a parameters of the device function. While this is legal, as TIR only requires SSA across each PrimFunc, this does result in failure to round-trip through TVMScript, because the round-tripped TIR uses a new tir::Var in each instance. This PR adds a ConvertSSA() transform that can apply to an entire IRModule, in addition to the existing ConvertSSA(Stmt) utility.

This is part of changes described in #14486, to improve round-trip failures that occur in lowering.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Apr 4, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

When passes create new PrimFuncs, such as when `tir.SplitHostDevice`
separates out a `tir::Stmt` into an independent function, the
parameters of these new function may alias existing variable
definitions.  While this is well-defined, because variable definitions
are not shared across function boundaries, it can give false
discrepancies from `tvm.ir.assert_structural_equal`.

This commit implements `tvm::tir::transform::ConvertSSA`, which
ensures unique variable declaration locations across an entire module.
Avoid duplicate variable defitions between the host and device
PrimFunc.
@Lunderberg
Copy link
Contributor Author

@tvm-bot rerun

@tqchen tqchen merged commit e8cd33b into apache:main Apr 8, 2023
@Lunderberg Lunderberg deleted the ssa_after_split_host_device branch April 8, 2023 17:45
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.

3 participants