-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Match get_attr when compare node #91657
Conversation
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/91657
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 FailuresAs of commit b6f5731: BROKEN TRUNK - The following jobs failed but were present on the merge base 6674583:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) ghstack-source-id: 177038217 Pull Request resolved: #91657
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
Pull Request resolved: #91657 The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` ghstack-source-id: 177158321 Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/)
elif pn.op == "get_attr": | ||
pn_value = getattr(pn.graph.owning_module, pn.target) | ||
gn_value = getattr(gn.graph.owning_module, gn.target) | ||
return isinstance(pn_value, torch.Tensor) and isinstance (gn_value, torch.Tensor) |
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.
I feel like we don't necessarily need to compare tensor data itself, torch.linear(10, 14) and torch.linear(12, 14) will have different weight and they should be matched, thought?
Also regarding
legal object
anything else I need to check here?
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
Pull Request resolved: #91657 The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` ghstack-source-id: 177201189 Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/)
gn_value = getattr(gn.graph.owning_module, gn.target) | ||
if type(pn_value) != type(gn_value): | ||
return False | ||
if isinstance(pn_value, torch.Tensor): |
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.
Please comment on we don't require exact match on tensor values.
return False | ||
if isinstance(pn_value, torch.Tensor): | ||
return isinstance (gn_value, torch.Tensor) | ||
else: |
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.
We should be able handle python literals, int/float/bool ect...
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.
Make sense. For python literals, i'm thinking they should be pass if the type is the same maybe?
Can we add some test? |
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.
Per comment and lint passing.
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
Pull Request resolved: #91657 The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` ghstack-source-id: 177318763 Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D42316574/)!
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
Pull Request resolved: #91657 The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` ghstack-source-id: 177318804 Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D42316574/)!
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) [ghstack-poisoned]
Pull Request resolved: #91657 The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` ghstack-source-id: 177319081 Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D42316574/)!
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
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 |
The pattern can't be matched if one attribute is `_param_constant1` and the other is `_param_constant0` Large graph: ``` # call_function addmm_default aten.addmm.default (_param_constant1, ph_0, _tensor_constant0) {} ``` Pattern graph ``` # call_function addmm_default aten.addmm.default (_param_constant0, ph_0, _tensor_constant0) {} ``` Differential Revision: [D42316574](https://our.internmc.facebook.com/intern/diff/D42316574/) Pull Request resolved: #91657 Approved by: https://github.com/SherlockNoMad ghstack-source-id: b39629bdacb7b02788061579c23585253b456157
Stack from ghstack (oldest at bottom):
The pattern can't be matched if one attribute is
_param_constant1
and the other is_param_constant0
Large graph:
Pattern graph
Differential Revision: D42316574