yelite opened a new issue, #11192:
URL: https://github.com/apache/tvm/issues/11192

   In TVMScript, there are places where literal string is used in type 
annotation as type parameter. For instance,
   ```
   @T.prim_func
   def main(A: T.Buffer[(8,), "float32"], B: T.Buffer[(8,), "float32"]):
   ```
   This will result in lint error `undefined name 'float32'` since linter (or 
type checker) treats literal string in type annotation as [forward 
references](https://peps.python.org/pep-0484/#forward-references). While there 
will not be any runtime errors, this makes editing TVMScript in modern editor 
less pleasant. This issue is opened to discuss the potential workaround for 
this problem.
   
   One possible approach is to have a magic object to turn symbol into string, 
like 
   ```
   class TypeString:
       def __getattribute__(self, name):
           return name
   
   T.type = TypeString()
   
   @T.prim_func
   def main(A: T.Buffer[(8,), T.type.float32], B: T.Buffer[(8,), 
T.type.float32]):
       ...
   ```


-- 
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: [email protected]

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

Reply via email to