yongwww commented on code in PR #14394:
URL: https://github.com/apache/tvm/pull/14394#discussion_r1155054422


##########
python/tvm/script/parser/relax/parser.py:
##########
@@ -220,7 +220,31 @@ def visit_tvm_declare_function(self: Parser, node: 
doc.FunctionDef) -> GlobalVar
             param_sinfo = eval_struct_info(self, arg.annotation, eval_str=True)
             params.append(relax.Var(arg.arg, param_sinfo))
 
-    func_signature = relax.Function.create_empty(params, ret_sinfo)
+    # find a call to R.func_attr to see if purity should be indicated
+    # namely, find a call to R.func_attr({..., "IsPure": val, ...})
+    # (we don't need any other attributes at the function declaration stage)
+    attrs = None
+    for item in node.body:
+        if (
+            isinstance(item, doc.Expr)
+            and isinstance(item.value, doc.Call)
+            and isinstance(item.value.func, doc.Attribute)
+            and item.value.func.attr == "func_attr"
+            and len(item.value.args) == 1
+            and isinstance(item.value.args[0], doc.Dict)

Review Comment:
   consider moving this to a func like `get_func_attrs`



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to