Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new pass for extracting subgraphs from an ONNX model based on exact input and output tensor names. Key changes include:
- Adding a new pass implementation in onnxscript/ir/passes/common/graph_extration.py.
- Enhancing pre- and post-condition checks in the pass infrastructure in onnxscript/ir/passes/_pass_infra.py.
- Exporting the new create_value_mapping function via the convenience modules.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| onnxscript/ir/passes/common/graph_extration.py | Implements the new ExtractGraphPass for subgraph extraction. |
| onnxscript/ir/passes/_pass_infra.py | Updates PassBase and PassManager for improved invariant checking. |
| onnxscript/ir/_convenience.py | Exports create_value_mapping and replace_nodes_and_values. |
| onnxscript/ir/convenience.py | Imports and re-exports create_value_mapping. |
Comments suppressed due to low confidence (1)
onnxscript/ir/passes/common/graph_extration.py:1
- The filename 'graph_extration.py' appears to be misspelled; consider renaming it to 'graph_extraction.py' for clarity.
# Copyright (c) Microsoft Corporation.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2119 +/- ##
==========================================
- Coverage 73.63% 67.64% -5.99%
==========================================
Files 227 229 +2
Lines 29134 29261 +127
Branches 3338 3352 +14
==========================================
- Hits 21453 19795 -1658
- Misses 6551 8376 +1825
+ Partials 1130 1090 -40 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* **Test extract subgraph**: Add a test case to validate the extraction of a subgraph with basic operations (Add, Mul). * **Test extract subgraph with initializers**: Add a test case to validate the extraction of a subgraph that includes initializers (Constant). * **Test extract subgraph with subgraph**: Add a test case to validate the extraction of a subgraph that includes nested subgraphs (If node with then and else branches).
There was a problem hiding this comment.
Change the copilot output
| @@ -0,0 +1,154 @@ | |||
| # Copyright (c) Microsoft Corporation. | |||
Check warning
Code scanning / lintrunner
RUFF/format Warning
| @@ -0,0 +1,154 @@ | |||
| # Copyright (c) Microsoft Corporation. | |||
Check warning
Code scanning / lintrunner
RUFF-FORMAT/format Warning
| @@ -0,0 +1,154 @@ | |||
| # Copyright (c) Microsoft Corporation. | |||
| # Licensed under the MIT License. | |||
| import unittest | |||
Check warning
Code scanning / lintrunner
RUFF/I001 Warning
|
Replaced by onnx/ir-py#294 |
Extract subgraphs with `onnx_ir.convenience.extract()`. Migrated from microsoft/onnxscript#2119. Requires #293 --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ExtractGraphPass) inonnxscript/ir/passes/common/graph_extration.py. This pass allows for the extraction of a sub-model defined by specific input and output tensor names.