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] Flatten SeqStmt on construction #14492

Merged
merged 13 commits into from
Apr 20, 2023
Merged

Conversation

Lunderberg
Copy link
Contributor

Previously, SeqStmt could be nested, making a distinction between the nested SeqStmt({SeqStmt({a,b}), c}) and the flat SeqStmt({a,b,c}), even though the two are semantically equivalent. This also caused an issue with round-trips through TVMScript, which does not preserve this distinction.

This commit updates the SeqStmt constructor and the SeqStmt visitor in StmtMutator to flatten nested sequential statements provided.

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

Previously, SeqStmt could be nested, making a distinction between the
nested `SeqStmt({SeqStmt({a,b}), c})` and the flat `SeqStmt({a,b,c})`,
even though the two are semantically equivalent.  This also caused an
issue with round-trips through TVMScript, which does not preserve this
distinction.

This commit updates the `SeqStmt` constructor and the `SeqStmt`
visitor in `StmtMutator` to flatten nested sequential statements
provided.
@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

The flattening still can produce ambiguous structure for `SeqStmt` of
size 0 and 1.  Normalizing so that `SeqStmt::Flatten` will
automatically unwrap when flattening produces a single statement, and
will convert to `Evaluate(0)` when flattening removes all statements.
@Hzfengsy
Copy link
Member

Sorry for the late response. Could you please rebase it again and let's merge it?

@Lunderberg
Copy link
Contributor Author

No worries (this has been on my back burner as well). Main has been merged into the PR branch to resolve conflicts, and now running through CI.

@Lunderberg
Copy link
Contributor Author

@tvm-bot rerun

@Hzfengsy Hzfengsy merged commit 2bb9698 into apache:main Apr 20, 2023
@Hzfengsy
Copy link
Member

Thanks @Lunderberg for the PR :)

@Lunderberg Lunderberg deleted the flatten_seqstmt branch April 20, 2023 13:07
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