You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/22 20:08:06 UTC

[GitHub] [tvm] Lunderberg commented on a diff in pull request #11097: [TVMScript] Support TVMScript meta-programming

Lunderberg commented on code in PR #11097:
URL: https://github.com/apache/tvm/pull/11097#discussion_r856517028


##########
python/tvm/script/context_maintainer.py:
##########
@@ -233,7 +240,7 @@ def lookup_symbol(self, name: str) -> Optional[Union[Buffer, Var]]:
         for symbols in reversed(self.symbols):
             if name in symbols:
                 return symbols[name]
-        return None
+        return self.closure_vars.get(name)

Review Comment:
   I'm running into some errors when a closure variable isn't already a `PrimExpr`.  In the example below, this will cause an error message saying that it cannot add together a `PrimExpr` and an int.
   
   ```python
   offset = 1
   
   @T.prim_func
   def func(A: T.Buffer[(1,), "int32"], B: T.Buffer[(1,), "int32"]):
       B[0] = A[0] + offset
   ```
   
   Whenever we pull a variable out of the closure, can we run it through `tvm.runtime.convert`?  That way, any expression type supported by the FFI would be converted to a TIR-supported format.
   
   ```python
   if name in self.closure_vars:
       return tvm.runtime.convert(self.closure_vars[name])
   ```



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