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


##########
src/script/printer/relax/utils.h:
##########
@@ -82,10 +84,47 @@ inline Optional<ExprDoc> StructInfoAsAnn(const relax::Var& 
v, const ObjectPath&
   if (!v->struct_info_.defined()) {
     return NullOpt;
   }
+  bool attempt_to_hide_struct_info = !d->cfg->show_all_struct_info;
+
   if (const auto* call = rhs.as<relax::CallNode>()) {
     static const Op& call_tir_op = Op::Get("relax.call_tir");
     static const Op& call_dps_packed_op = Op::Get("relax.call_dps_packed");
     if (call->op.same_as(call_tir_op) || call->op.same_as(call_dps_packed_op)) 
{
+      attempt_to_hide_struct_info = true;
+    }
+  }
+  if (attempt_to_hide_struct_info) {

Review Comment:
   My worry with having separate rules for it is that those rules could diverge 
from the actual struct inference.  Even when the syntactic rules allow the 
struct info to be hidden, it would still need to compare against the actual 
struct info to see if the annotations provide different information.  That 
comparison would require StructInfo to compare against, and so this function 
would effectively be another implementation of `InferStructInfo`, but one which 
could get out of sync with the canonical version.
   
   By implementing it in terms of the struct inference, the same inference 
rules are used for both parsing and printing.  Just as parsing can fill in 
missing information by calling the type inference, the printing can check if 
information can be omitted by calling the type inference.



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