-
Notifications
You must be signed in to change notification settings - Fork 82
[Rewriter] Implement zero bias removal for Conv operations and related rules #2555
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
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
Hey @justinchuby, can you review this? |
@AyoubMDL would you be able to help review/critique? Thanks! |
…nd QLinearConv operations with additional tests
@AyoubMDL I made the changes you suggested... |
@whyvineet please allow reviewers to resolve comments so they get a chance to validate the changes. Thanks. |
@AyoubMDL I've made the changes you suggested, except for the last one... After getting further clarity, I'll start working on that as well... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2555 +/- ##
==========================================
- Coverage 70.33% 63.94% -6.39%
==========================================
Files 222 224 +2
Lines 26656 26786 +130
Branches 2666 2679 +13
==========================================
- Hits 18748 17128 -1620
- Misses 6992 8811 +1819
+ Partials 916 847 -69 ☔ View full report in Codecov by Sentry. |
…ance clarity in Conv, ConvTranspose, QLinearConv, and Gemm operations
@AyoubMDL, I have completed the modifications recommended by you... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ! some final remarks.
original_inputs = list(node.inputs) | ||
inputs_without_bias = original_inputs[:-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my suggestion on Gemm, you can remove this. And pass x, w as arguments to the rewrite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of hardcoding x
and w
parameters, the base class can dynamically handle any number of inputs by filtering out just the bias parameter ('b') and keeping everything else in the new changes made by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can pass some attributes when testing to check that every info is correctly transferred (e.g. stride, transA...)
…ias removal logic
…e attributes in Conv, ConvTranspose, Gemm, and QLinearConv operations
@AyoubMDL, is there anything else I should update or improve? |
inputs_without_bias = original_inputs[:-1] | ||
# Filter out the bias parameter and keep all other inputs | ||
inputs = [] | ||
for param_name, param_value in _.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now... There was just a misunderstanding on my part!
…ng efficiency in _RemoveZeroBiasBase class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good to me. I'll let @justinchuby share additional comments
Thanks for the guidance @AyoubMDL! And I don't know how I missed |
@justinchuby, can you explain why these checks are failing? I reviewed the logs but didn't gain much clarity... |
) | ||
|
||
|
||
def _apply_rule_and_check_optimization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is a little too complicated to maintain. Please check other tests in the directory and simplify.
The error is saying the Sequence[int] attributes are supposed to be tuples but the expected values are lists. You can check where you provide the expected outputs. |
This line onnxscript/rewriter/rules/common/_remove_zero_bias_test.py:76: in _apply_rule_and_check_optimization |
…t/onnxscript into remove-optional-bias
… and improved clarity
self.v1.dtype = ir.DataType.BFLOAT16 | ||
self.v2 = ir.val(name="v2", shape=ir.Shape([2, 3, 4])) | ||
self.v2.dtype = ir.DataType.BFLOAT16 | ||
self.v0 = ir.Value( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert. ir.val is a convenience function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was failing test cases... Okh I'll do so!
Please use judgement before applying AI edits, and please engage the reviewers if you have clarification questions. It is preferred if you understand what the edits should be before spending time doing them. Have a discussion and lay out your thought process before taking actions. Pure AI edits that don't help with addressing the issues raised in reviews and is a waste of everyone's time. |
…sistency and improved clarity" This reverts commit 86de85f.
…tuple differences
I understand your point and will make sure to carefully consider the purpose of edits and engage reviewers before applying changes in future commits and PRs. |
Fix #2547