You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "liangW-intellif (via GitHub)" <gi...@apache.org> on 2023/02/01 12:10:47 UTC

[GitHub] [tvm] liangW-intellif opened a new issue, #13892: [Bug] TVMScript fails with LetStmt

liangW-intellif opened a new issue, #13892:
URL: https://github.com/apache/tvm/issues/13892

   Hi there,
   I encountered an error that when generating TVMScript with LetStmt, the generated script cannot be parsed if the var in LetStmt appears the first time in the IR.
   ```
   import tvm
   from tvm.script import tir as T
   from tvm import te
   
   
   def test_let_roundtrip():
       x = te.var("x")
       y = te.var("y")
       let0 = tvm.tir.LetStmt(x, 0, tvm.tir.Evaluate(0))
       let1 = tvm.tir.LetStmt(y, 1, tvm.tir.Evaluate(0))
       body = tvm.tir.SeqStmt([let0, let1])
       func = tvm.tir.PrimFunc([], body)
       print(func.script())
       # Parse fail
       roundtrip = tvm.script.from_source(func.script())
       tvm.ir.assert_structural_equal(func, roundtrip, True)
   ```
   
   
   The above case generates TVMScript as below
   ```
   @T.prim_func
   def main():
       with T.let(x, 0):
           T.evaluate(0)
       y: T.int32 = 1
       T.evaluate(0)
   ```
   But when parsing this TVMScript, it reports an error that 'x' is an undefined variable so that the parse failed. The TVMScript with LetStmt is not round-trippable in this case.
   
   ```
   test_let_roundtrip.py::test_let_roundtrip # from tvm.script import tir as T
   
   @T.prim_func
   def main():
       with T.let(x, 0):
           T.evaluate(0)
       y: T.int32 = 1
       T.evaluate(0)
   error: Undefined variable: x
    --> <str>:5:16
      |  
    5 |      with T.let(x, 0):
      |                 ^     
   FAILED
   ```
   
   For the semantic of LetStmt, I think'x' should be identified as a definition, the script should be parsed successly.
   
   Please let me know if there is any confusion, thanks very much!
   
   ### Environment
   
   latest TVM mainline
   
   @junrushao  @wrongtest-intellif


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] junrushao closed issue #13892: [Bug] TVMScript fails with LetStmt

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao closed issue #13892: [Bug] TVMScript fails with LetStmt
URL: https://github.com/apache/tvm/issues/13892


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] cyx-6 commented on issue #13892: [Bug] TVMScript fails with LetStmt

Posted by "cyx-6 (via GitHub)" <gi...@apache.org>.
cyx-6 commented on issue #13892:
URL: https://github.com/apache/tvm/issues/13892#issuecomment-1412790845

   Thanks for reporting this bug. I believe that this is due to the bug of printing `LetStmt`. Since we forget to print the `x = T.var("int32")` before the `with T.let(x, 0):`. This bug will be fixed in the #13900. And more details are in the description of that PR too.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] junrushao commented on issue #13892: [Bug] TVMScript fails with LetStmt

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on issue #13892:
URL: https://github.com/apache/tvm/issues/13892#issuecomment-1412186248

   CC @cyx-6 would you like to take a look? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] junrushao commented on issue #13892: [Bug] TVMScript fails with LetStmt

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on issue #13892:
URL: https://github.com/apache/tvm/issues/13892#issuecomment-1416251547

   Closed via #13900 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org