-
Couldn't load subscription status.
- Fork 25.7k
[quant][fx] Add support for matching multiple arguments in patterns #89986
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
Conversation
Summary: This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype Test Plan: python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89986
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3b06dbd: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
… patterns" Summary: This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype Test Plan: python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args Reviewers: Subscribers: Tasks: Tags: cc jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel [ghstack-poisoned]
Summary: This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype Test Plan: python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: d567c7b Pull Request resolved: #89986
| self.checkGraphModuleNodes(m_ref, expected_node_occurrence=node_occurrence_ref) | ||
|
|
||
| def test_match_pattern_with_multiple_args(self): | ||
| """ Test that we can match a pattern that has multiple arguments |
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.
what does "multiple arguments" mean?
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 means reshape has multiple arguments, also added in the docstring
| return transpose | ||
|
|
||
| backend_pattern_configs.append( | ||
| BackendPatternConfig((torch.reshape, torch.transpose, MatchAllNode)) |
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 looks like a pattern of a -> b -> c, could we explain what specifically is different about this compare to what's already supported?
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 means a(b(input1), c(input2)) actually, sure, I'll add more explanations
… patterns"
Summary:
This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype
Before this PR, we only support patterns like:
```
x -> conv -> bn -> relu
(relu, (bn, conv))
```
where each operator has a single node, the code breaks when we want to match a pattern that has an op that has multiple arguments, such as:
```
shape \
transpose -> reshape -> output ->
```
where `reshape` has two arguments
Test Plan:
python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args
Reviewers:
Subscribers:
Tasks:
Tags:
cc jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel
[ghstack-poisoned]
Summary: This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype Test Plan: python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: ae6e866 Pull Request resolved: #89986
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…ytorch#89986) Summary: This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype Before this PR, we only support patterns like: ``` x -> conv -> bn -> relu (relu, (bn, conv)) ``` where each operator has a single node, the code breaks when we want to match a pattern that has an op that has multiple arguments, such as: ``` shape \ transpose -> reshape -> output -> ``` where `reshape` has two arguments Test Plan: python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: pytorch#89986 Approved by: https://github.com/vkuzo
Stack from ghstack (oldest at bottom):
Summary:
This PR adds support for matching patterns that has multiple arguments, it's needed for quantization in PyTorch 2.0 early prototype
Before this PR, we only support patterns like:
where each operator has a single node, the code breaks when we want to match a pattern that has an op that has multiple arguments, such as:
where
reshapehas two argumentsTest Plan:
python test/test_quantization.py TestQuantizeFx.test_match_pattern_with_multiple_args
Reviewers:
Subscribers:
Tasks:
Tags:
cc @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel