ZihengJiang opened a new pull request #7084:
URL: https://github.com/apache/tvm/pull/7084


   This PR supports building TIR function directly and allows TIR returns value 
directly. 
   Current approach is by adding an intrinsic for `return`.  Example:
   ```python
   def add():
       a = tir.Var("a", "float32") 
       b = tir.Var("b", "float32") 
       c = a + b
       c = tir.call_intrin("float32", "tir.myreturn", c) 
       c = tir.Evaluate(c)
       func = tir.PrimFunc([a, b], c)
       mod = tvm.IRModule({'add': func})
       func = tvm.build(mod['add'])
       out = func(1.0, 2.0)
       print(out)
   ```
   
   In the future, with the tvm script, we should be able to write some like:
   ```python
   @tvm.script
   def add(a, b):
       tir.myreturn(a + b)
   ```
   
   There are two things need to be discussed:
   - Because `return` is a keyword in Python, currently I use `myreturn`, we 
should have another name for it.
   - Whether we should support multiple `return` in a single function.
   
   @tqchen @junrushao1994 @areusch 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to