-
Notifications
You must be signed in to change notification settings - Fork 72
[IR] Introduce node convenience functions #2303
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] Introduce node convenience functions #2303
Conversation
Convenience function to insert a set of nodes in value(s).
Convenience function to remove a set of nodes.
8239060
to
e89df33
Compare
Thanks - I will get to it hopefully some time this week |
graph.sort() | ||
|
||
|
||
def remove_nodes(nodes: Sequence[_core.Node]) -> None: |
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 is very useful, thanks
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 call it remove_connected_nodes ? Also could you move this PR to https://github.com/onnx/ir-py now that we finished migration? (sorry about the extra effort) I recommend creating two PRs for the two functions so they can be reviewed individually
@justinchuby, I forgot to ask something: when you finish reviewing, I would like to discuss with you about the implementation and see the possibility of updating |
Sure - happy to explore. I may need a few more days to review this PR. I am occupied with some other tasks at the moment |
Do not worry. Thanks! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2303 +/- ##
==========================================
- Coverage 73.86% 68.34% -5.53%
==========================================
Files 243 244 +1
Lines 31213 31363 +150
Branches 3537 3547 +10
==========================================
- Hits 23055 21434 -1621
- Misses 6930 8752 +1822
+ Partials 1228 1177 -51 ☔ View full report in Codecov by Sentry. |
"""Find the values that are considered as inputs and outputs in a sequence of nodes""" | ||
# Search the unique inputs/outputs in new_nodes, keeping the order. | ||
all_inputs = dict.fromkeys(sum([node.inputs for node in nodes], ())) | ||
all_outputs = dict.fromkeys(sum([node.outputs for node in nodes], ())) |
Check notice
Code scanning / lintrunner
RUFF/C419 Note
See https://docs.astral.sh/ruff/rules/unnecessary-comprehension-in-call
# Search the unique inputs/outputs in new_nodes, keeping the order. | ||
all_inputs = dict.fromkeys(sum([node.inputs for node in nodes], ())) | ||
all_outputs = dict.fromkeys(sum([node.outputs for node in nodes], ())) | ||
# A value is considered as input if it is not any output. |
Check notice
Code scanning / lintrunner
RUFF/C419 Note
See https://docs.astral.sh/ruff/rules/unnecessary-comprehension-in-call
@@ -0,0 +1,248 @@ | |||
# Copyright (c) Microsoft Corporation. |
Check warning
Code scanning / lintrunner
RUFF/format Warning
# Licensed under the MIT License. | ||
"""Unit tests for the _constructors module.""" | ||
|
||
import onnx |
Check warning
Code scanning / lintrunner
RUFF/I001 Warning
See https://docs.astral.sh/ruff/rules/unsorted-imports
|
||
import onnx | ||
|
||
import unittest |
Check notice
Code scanning / lintrunner
PYLINT/C0411 Note
See wrong-import-order. To disable, use # pylint: disable=wrong-import-order
@justinchuby I see that it is no longer possible to merge this work here. Do you want me to move it to ir-py ? |
Yes please, thanks! |
Closing this PR, moving to onnx/ir-py#63 |
Introduce
insert_nodes_in_value
andremove_nodes
convenience functions to insert and remove nodes, respectively.Close #2294