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


##########
src/relax/ir/expr.cc:
##########
@@ -473,6 +473,23 @@ Function::Function(Array<Var> params, Expr body, 
Optional<StructInfo> ret_struct
     ret_struct_info = body_sinfo;
   }
 
+  bool is_pure = [&]() -> bool {

Review Comment:
   Currently, the struct info for a `GlobalVar` is determined only by the 
forward declaration, and not by its body.  The default for this is determined 
here 
([here](https://github.com/apache/tvm/blob/main/python/tvm/script/parser/relax/parser.py#L247)),
 where a function is pure unless explicitly annotated otherwise.
   
   We have a similar problem with return values, where the inferred return type 
of a function may not omitted, resulting in incorrect struct inference in the 
calling scope.  I think the long-term solution to both is the same: To 
represent the lack of information while parsing, and to infer full information 
as a post-proc.



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