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

[RFC] Relax Language Specification #106

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

slyubomirsky
Copy link

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.

@@ -276,12 +276,13 @@ To simplify the writing of Relax passes, we define a normal form for Relax progr

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).
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for making the updates here, and this looks accurate to the changes after apache/tvm#16658

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.

None yet

2 participants