Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

cccclai
Copy link
Contributor

@cccclai cccclai commented Jan 3, 2023

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:

        # 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

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]
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 3, 2023

🔗 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 Failures

As 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.

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Jan 3, 2023
cccclai added a commit that referenced this pull request Jan 3, 2023
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]
cccclai added a commit that referenced this pull request Jan 5, 2023
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)
Copy link
Contributor Author

@cccclai cccclai Jan 5, 2023

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]
cccclai added a commit that referenced this pull request Jan 5, 2023
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):
Copy link
Contributor

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:
Copy link
Contributor

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...

Copy link
Contributor Author

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?

@SherlockNoMad
Copy link
Contributor

Can we add some test?

Copy link
Contributor

@SherlockNoMad SherlockNoMad left a 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]
cccclai added a commit that referenced this pull request Jan 9, 2023
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]
cccclai added a commit that referenced this pull request Jan 9, 2023
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]
cccclai added a commit that referenced this pull request Jan 9, 2023
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/)!
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 9, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

NicolasHug added a commit that referenced this pull request Jan 9, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: fx release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants