-
Notifications
You must be signed in to change notification settings - Fork 54
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
[IR] Implement replace_all_uses_with #1414
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1414 +/- ##
==========================================
- Coverage 76.90% 76.88% -0.03%
==========================================
Files 209 209
Lines 22406 22414 +8
Branches 3795 3797 +2
==========================================
Hits 17232 17232
- Misses 4463 4468 +5
- Partials 711 714 +3 ☔ View full report in Codecov by Sentry. |
Test Results 28 files ± 0 28 suites ±0 3h 47m 28s ⏱️ - 10m 29s For more details on these failures, see this check. Results for commit 796b46c. ± Comparison against base commit 5a0cd8e. This pull request removes 1282 and adds 1 tests. Note that renamed tests count towards both.
|
from onnxscript.ir import _core, _protocols | ||
|
||
|
||
def convert_attributes(attrs: Mapping[str, Any]) -> list[_core.Attr]: |
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.
Is this the same as the one in _tape.py ? We can presumably use this there?
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.
Sure! I will create a follow up
replacements = (replacements,) | ||
if len(values) != len(replacements): | ||
raise ValueError("The number of values and replacements must match.") | ||
for value, replacement in zip(values, replacements): |
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.
A question about the IR: how is a (missing) optional output represented? Does it have a corresponding Value object or is it represented as None in the node's outputs? Wondering if we should handle the possibility of None being here.
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 wasn't aware that an empty output was possible, so I didn't handle them anywhere. I will create a pr to implement empty output support.
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.
Correction: an empty output is represented as a Value whose name is ""
. It will not have any users so we don't need to do anything about it.
Create a convenience function
replace_all_uses_with
to replace uses of values. Test with doctest.Rename convenience to _convenience. We should expose some of the methods once they are proven to be useful.