tqchen commented on PR #16356:
URL: https://github.com/apache/tvm/pull/16356#issuecomment-1881146389

   Just want to bring up some background on annotations and complications in 
struct info.
   
   Given the complication of the relax struct info annotation, we cannot 
guanrantee that the struct info can always be inferred in a reproducible manner 
from rhs. This is also one reason why we always require the annotation to be 
printed out.
   
   The primary reason is when the struct info itself can involve complicated 
bindings
   ```
   def example(x: R.Tensor):
           s = shape_func(x)
           y: R.Tensor[s] = opaque_fn(x)   
   ```
   
   Removing the annotation ` R.Tensor[s]` again would cause the deduction of 
`opaque_fn` to retrigger, which results in the parsed back function as 
   ```c++
   def example(x: R.Tensor):
           s = shape_func(x)
           s1 = shape_func(x)
           y: R.Tensor[s1] = opaque_fn(x)   
   ```
   
   While semantically it is still ok after DCE, however, it is not always 
desirable. more complicated case can ocurr when the set of annotations involve 
other set of computations, where some may have common sub expressions (e.g. 
same shape_func calls being combined after some pass).
   
   The main take-away here is that in order for the parser to be able to fully 
roundtrippable, we would need to rely on the annotations on the lhs. 
   
   While it is ok to toggle off the signature printing, I think we should note 
that this will no longer guarantee roundtripping.


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