Skip to content

Unify failure-handling in rewrite-rule#2866

Merged
gramalingam merged 4 commits intomainfrom
rama/rewriter-error
Mar 27, 2026
Merged

Unify failure-handling in rewrite-rule#2866
gramalingam merged 4 commits intomainfrom
rama/rewriter-error

Conversation

@gramalingam
Copy link
Copy Markdown
Collaborator

Unify failure-handling in rewrite-rule

Signed-off-by: G Ramalingam <[email protected]>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.93%. Comparing base (19e5284) to head (7385eab).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/rewriter/_rewrite_rule.py 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2866      +/-   ##
==========================================
+ Coverage   71.86%   71.93%   +0.06%     
==========================================
  Files         239      239              
  Lines       29138    29199      +61     
  Branches     2875     2877       +2     
==========================================
+ Hits        20941    21004      +63     
+ Misses       7219     7217       -2     
  Partials      978      978              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make rewrite-rule failure signaling consistent with the existing conventions used by check functions, so rule authors can use the same “fail” mechanisms in both phases and get better diagnostics via tracer reporting.

Changes:

  • Extend rewrite replacement handling to treat None/False, falsy MatchResult, and MatchFailureError as “rewrite failed” signals.
  • Add unit tests covering the supported rewrite failure conventions.
  • Update the rewriter tutorial documentation to describe the unified failure conventions for checks and rewrites.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
onnxscript/rewriter/pattern_base_test.py Adds tests validating rewrite functions’ supported failure conventions.
onnxscript/rewriter/_rewrite_rule.py Implements unified failure handling in replacement generation (get_replacement).
docs/tutorial/rewriter/node_value_checkers.md Documents unified failure conventions for check + rewrite functions.

@gramalingam gramalingam enabled auto-merge (squash) March 26, 2026 23:28
@gramalingam gramalingam merged commit 1077da7 into main Mar 27, 2026
30 of 33 checks passed
@gramalingam gramalingam deleted the rama/rewriter-error branch March 27, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants