csullivan commented on pull request #8017:
URL: https://github.com/apache/tvm/pull/8017#issuecomment-842523174


   Good question, the Type subclasses can be used as a type_annotation to [tir 
variables](https://github.com/csullivan/incubator-tvm/blob/main/include/tvm/tir/var.h#L61).
 Code generation specifically relies on this type annotation to correctly write 
an op's function signature and the accesses of that Var. 
   
   Taking #7686 as an example, when generating a function signature for `var` 
s.t.,
   ```
   var = Var("a_buffer_var", PointerType(PrimType("float16"), "global.texture"))
   ```
   we expect PrintType(var) to return `image2d_t` in OpenCL. In Metal this may 
be `texture2d<half,>`. 
   
   That's not to say we couldn't use the AST annotation to annotate Vars, but 
this would require all lowering to respect the fact that Vars may have 
annotations and thus to carry them forward if any Var binding occurs. OTOH if 
the storage_scope is part of the type system it is guaranteed to be preserved.


-- 
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:
us...@infra.apache.org


Reply via email to