-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] kill _parameter_list #27399
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
[jit] kill _parameter_list #27399
Conversation
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date.
zdevito
left a comment
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.
Thanks for cleaning this up.
torch/jit/quantized.py
Outdated
| if dtype == torch.int8: | ||
| self._orig_weights_names = self._packed_weights_names | ||
|
|
||
| self._packed_weights = torch.jit.Attribute([getattr(self, weight) for weight in self._packed_weights_names], List[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.
Do we need to have torch.jit.Attribute or does it work to put the types in __attributes__?
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.
It needs to be an attribute with the current ScriptModule API, but not after my rewrite.
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date.
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date.
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Differential Revision: [D17785658](https://our.internmc.facebook.com/intern/diff/D17785658)
1 similar comment
Summary: Pull Request resolved: pytorch#27399 This was devised in a time when we didn't have module attributes. They are essentially just tensor lists, so represent them that way. This has the additional benefit of making the RNN forward pass faster because we effectively cache the flattened weights. The only complication part is that someone may come along and do: ``` my_rnn_mod.w_ih_l0 = torch.nn.Parameter(...) ``` This means we need to override setattr to keep the flattened weights cache up to date. Test Plan: Imported from OSS Differential Revision: D17785658 Pulled By: suo fbshipit-source-id: 7789cd1d0d4922bfd5eba1716976442fbf150766
Stack from ghstack:
This was devised in a time when we didn't have module attributes. They
are essentially just tensor lists, so represent them that way. This has
the additional benefit of making the RNN forward pass faster because we
effectively cache the flattened weights.
The only complication part is that someone may come along and do:
This means we need to override setattr to keep the flattened weights
cache up to date.
Differential Revision: D17785658