Open
Conversation
Lunderberg
reviewed
Mar 14, 2024
| The normal form for Relax is very similar to ANF; differences will be noted. Here are the criteria required for a program to be in normal form: | ||
| 1. Within a `SeqExpr`, the right-hand side of any binding (the `value` field in the AST) must either be a "leaf expression" or a non-leaf expression where all subexpressions are leaf expressions. Leaf expressions are the following: Variables (`Var`, `DataflowVar`, or `GlobalVar`), `Constant`, `ShapeExpr`, `PrimValue`, `StringImm`, `DataTypeImm`, or (_unlike_ ANF) `Tuple`. `Tuple` nodes are considered "leaf" expressions even though they contain nesting purely for convenience in writing passes; many operators rely on grouping arguments using tuples, so that is a form of nesting permitted and expected. Otherwise, non-leaf expressions used as subexpressions must be bound to variables; this includes any non-leaf expressions nested inside a `Tuple`. | ||
| 2. `SeqExpr`s may appear only in the following locations: | ||
| 2. As an addition to the above, all variables of type `TupleStructInfo([])`, the unit tuple, are inlined during normalization. That is, all uses of variables with the type `TupleStructInfo([])` will be replaced directly with the value `Tuple([])` (the unit tuple). |
Contributor
There was a problem hiding this comment.
Thank you for making the updates here, and this looks accurate to the changes after apache/tvm#16658
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rendered view.
Now that Unity has been merged into TVM's main branch, I have written an RFC to make my unofficial Relax specification an official one, akin to the TIR specification RFC. Since Relax is a much newer and less heavily used language than TIR, there are fewer unresolved questions in this RFC compared to that for the TIR specification. I welcome your review both on the specification draft itself and on the procedures proposed in the RFC.
Many thanks to those who have reviewed past versions of the draft Relax specification, including @YuchenJin, @psrivas2, @sunggg, @junrushao, @denise-k, and @yongwww.