Skip to content

Updates to the rewriter tutorial #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Updates to the rewriter tutorial #2397

wants to merge 6 commits into from

Conversation

gramalingam
Copy link
Collaborator

Updates to the rewriter tutorial

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Copy link
Contributor

@Copilot 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 updates the rewriter tutorial documentation by improving explanations and demonstrating an alternative class-based approach to defining rewrite rules.

  • Introduces a class-based rewrite rule example in the tutorial.
  • Enhances documentation on conditional rewrite rules and commutativity handling.
  • Updates the index order and adjusts descriptive text in several markdown files.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/tutorial/rewriter/simple_example.md Refactored the tutorial to demonstrate an alternative class-based definition for rewrite rules.
docs/tutorial/rewriter/rewrite_patterns.md Updated text to indicate that rewrite rules are conditional.
docs/tutorial/rewriter/examples/erfgelu.py Added a new class-based rewrite rule implementation example.
docs/tutorial/rewriter/conditional_rewrite.md Revised explanation for condition checking with additional IR details.
docs/tutorial/rewriter/commute.md Expanded discussion on commutativity handling and introduced a warning regarding rule explosion.
docs/tutorial/index.md Adjusted the ordering for the toctree entries.
Comments suppressed due to low confidence (1)

docs/tutorial/rewriter/simple_example.md:65

  • Consider revising the sentence to include a verb, for example: 'This parameter is either a Sequence[PatternRewriteRule] or a RewriteRuleSet.'
2. `pattern_rewrite_rules` : This parameter either a `Sequence[PatternRewriteRule]` or a `RewriteRuleSet`.

@@ -31,7 +31,11 @@ The target pattern in this case has 5 inputs `input_a`, `input_b`, `shape_a`, `s
Similarly for writing the condition checking function, we require only `input_a`, `input_b` and `shape_c`. Use `**_` to represent all the unused parameters in the condition matching function signature.
:::

In order to validate whether matmul broadcast is sufficient, we write a condition checking function as follows:
In order to validate whether matmul broadcast is sufficient, we write a condition checking function as below.
Note that the relevant inputs passed to the check function are all instances of `ir.Value`. These represent
Copy link
Collaborator

@justinchuby justinchuby Jun 18, 2025

Choose a reason for hiding this comment

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

Suggested change
Note that the relevant inputs passed to the check function are all instances of `ir.Value`. These represent
Note that the relevant inputs passed to the check function are all instances of :class:`onnx_ir.Value`. These represent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will this work, given that IR has moved to a different repo? Not sure if the old documentation still exists, but still ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did add a reference to the overall documentation in the lines below.

@justinchuby justinchuby added the topic: documentation Improvements or additions to documentation label Jun 18, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Improvements or additions to documentation
Projects
Development

Successfully merging this pull request may close these issues.

2 participants