Commit dd20e10
Adjust _pre_load_state_dict_hook to skip excluded tensors (meta-pytorch#3208)
Summary:
Pull Request resolved: meta-pytorch#3208
For more context please refer to S539698
We see key errors when calling `_pre_load_state_dict_hook`. Upon code inspection, we see the following pattern, a dictionary key is manually constructed (https://fburl.com/code/kg6b1y97), and then code directly calls `state_dict[key]`, without checking if a key is in the state dict.
With this change we skip keys that are not in state dict, which avoid keyerror
Reviewed By: iamzainhuda
Differential Revision: D78511161
fbshipit-source-id: 2fa5cc6ef04ecfad15ecfec6731ef3ed5579e3ec1 parent 45d5c4d commit dd20e10
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
839 | 844 | | |
840 | 845 | | |
841 | 846 | | |
| |||
0 commit comments