-
Notifications
You must be signed in to change notification settings - Fork 64
[Pass] Graph extractor pass #2119
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
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.
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.
❌ 8 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
See https://docs.astral.sh/ruff/rules/unsorted-imports
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.