You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "slyubomirsky (via GitHub)" <gi...@apache.org> on 2024/02/14 21:35:18 UTC

Re: [PR] [Unity][Parser] Check well-formedness in the parser [tvm]

slyubomirsky commented on code in PR #16569:
URL: https://github.com/apache/tvm/pull/16569#discussion_r1490094703


##########
python/tvm/script/parser/core/entry.py:
##########
@@ -77,4 +95,15 @@ def parse(program: Union[doc.AST, Any, str], extra_vars: Dict[str, Any] = None)
             parser.parse(extra_vars=extra_vars)
         except ParserError as err:
             parser.report_error(err.node, err.args[0])
-    return builder.get()
+    ret = builder.get()
+    # well-formedness check will ignore any non-Relax functions
+    if isinstance(ret, IRModule):
+        # note: use the walrus operator (:=) once the project Python version
+        # supports it, would be more concise
+        source_ast = source.as_ast()
+        if find_decorator_annotation(source_ast, "check_well_formed") and not well_formed(ret):

Review Comment:
   Mmm, handling the failing test cases will be a lot harder without this capability so I will see how I can improve the parser.



-- 
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-unsubscribe@tvm.apache.org

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