[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.
This is very useful, thanks
There was a problem hiding this comment.
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
| # 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
| @@ -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
|
|
||
| import onnx | ||
|
|
||
| import unittest |
Check notice
Code scanning / lintrunner
PYLINT/C0411 Note
|
@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_valueandremove_nodesconvenience functions to insert and remove nodes, respectively.Close #2294