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

[PR] [Relax][Bugfix] Provide the full Expr to pattern-match rewriter [tvm]

Lunderberg opened a new pull request, #16828:
URL: https://github.com/apache/tvm/pull/16828

   This resolves a bug that was introduced in https://github.com/apache/tvm/pull/16732.  If a rewriter function returned a no-op, and the pattern-match continued, then the `matches` provided to the rewriter function in subsequent calls would contain a variable to which the matched expression was bound, not the matched expression itself.  (e.g. For a match of `C = R.add(A,B)`, passing `C` to the rewriter instead of `R.add(A,B)`.)
   
   This bug was caused by incorrect re-wrapping of `OrPattern` in `ExprPatternRewriter`.  Prior to https://github.com/apache/tvm/pull/16732, all pattern-match results were populated by `ExtractMatchExpr`, and contained the result after applying `TryGetValOfVar`.  When re-wrapping the result of an `OrPattern`, https://github.com/apache/tvm/pull/16732 populated the additional matches with the result before applying `TryGetValOfVar`. This commit fixes the bug by applying `TryGetValOfVar`.


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


Re: [PR] [Relax][Bugfix] Provide the full Expr to pattern-match rewriter [tvm]

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on PR #16828:
URL: https://github.com/apache/tvm/pull/16828#issuecomment-2030993908

   > Thank you for fixing it and providing a test case.
   
   Thank you, though @MasterJH5574 deserves credit for making the test case.  That helped quite a bit in narrowing down where the bug was occurring, and was very much appreciated.


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


Re: [PR] [Relax][Bugfix] Provide the full Expr to pattern-match rewriter [tvm]

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on code in PR #16828:
URL: https://github.com/apache/tvm/pull/16828#discussion_r1546331379


##########
tests/python/relax/test_dataflow_pattern.py:
##########
@@ -1952,5 +1952,38 @@ def expected():
     tvm.ir.assert_structural_equal(expected, after)
 
 
+def test_backtrack_for_no_op_rewriter_does_not_match_on_var():
+    """The matches should always contain the bound value
+
+    This is a regression test.  In versions from
+    https://github.com/apache/tvm/pull/16732 to
+    https://github.com/apache/tvm/pull/#####, the `rewrite_call`

Review Comment:
   Thank you, and fixed!



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


Re: [PR] [Relax][Bugfix] Provide the full Expr to pattern-match rewriter [tvm]

Posted by "MasterJH5574 (via GitHub)" <gi...@apache.org>.
MasterJH5574 commented on code in PR #16828:
URL: https://github.com/apache/tvm/pull/16828#discussion_r1546327801


##########
tests/python/relax/test_dataflow_pattern.py:
##########
@@ -1952,5 +1952,38 @@ def expected():
     tvm.ir.assert_structural_equal(expected, after)
 
 
+def test_backtrack_for_no_op_rewriter_does_not_match_on_var():
+    """The matches should always contain the bound value
+
+    This is a regression test.  In versions from
+    https://github.com/apache/tvm/pull/16732 to
+    https://github.com/apache/tvm/pull/#####, the `rewrite_call`

Review Comment:
   It's 16828 now.



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


Re: [PR] [Relax][Bugfix] Provide the full Expr to pattern-match rewriter [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #16828:
URL: https://github.com/apache/tvm/pull/16828


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