-
Notifications
You must be signed in to change notification settings - Fork 58
[UX][TVMScript] Feature requests #202
Comments
Shadowing example courtesy of @junrushao1994:
This brings up a related issue: Perhaps we should be allowed to reuse the same variable names in different scopes, also via shadowing.
|
Integer literals should be parsed into scalars: @R.function
def return_int() -> Tensor((), "int32"):
return 1 # presently fails to parse because it treats 1 as an IntImm, but should be parsed into a constant literal Similarly, empty tuples should parse: @R.function
def return_unit() -> Tuple():
return () # presently fails to parse |
Those will be fixed with the new parser. CC: @Hzfengsy @yongwww |
|
seems are supported through new parser |
Earlier discussion between myself and @junrushao1994, @YuchenJin, and others suggested that there are various aspects we are interested in improving about the Relax parser, so we would like to start this thread to keep track of changes we would like to make, particularly as we consider substantial revisions to the parsing infrastructure per apache/tvm-rfcs#79 (thanks to @cyx-6).
Here are some of the issues I've run into with the parser that we may want to consider changing:
(x,)[0]
). While strange, this has a logical interpretation and should not be rejected.ExternFunc
s that have side effects, there may not be a return value to bind. This can be parsed as having a binding to a fresh and never-again-used variable. (Unrelated semantics issue: If we do bind the result of aPackedFunc
that doesn't return anything to a variable, what type should the variable have? The Python FFI treats the resulting value asNone
, but there is no notion ofNone
in the Relax language, so should we perhaps turn them into empty tuples?)ExternFunc
s with side effects, it may not make sense to return a value. We could parse this as aSeqExpr
whosebody
field is an empty tuple. (This is related to the above semantics question, I guess.)The text was updated successfully, but these errors were encountered: