Skip to content

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 Lunderberg force-pushed the ssa_after_split_host_device branch from 0da86aa to bb768b0 Compare April 4, 2023 16:49
@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