Commit 4944790
Recognize re-exported PyTorch Tensor in efficiency lints
Summary:
PyTorch exposes its public `torch.Tensor` type through an internal re-export in common stub layouts, so the efficiency lints could see a resolved tensor class while still rejecting it because the defining name was not exactly `torch.Tensor`. This made the opt-in lint group look inert in real projects even though the synthetic tests passed.
Treat the canonical resolved implementation target for `torch.Tensor` as a PyTorch tensor while keeping the match narrow enough to avoid assuming every `Tensor` class under the torch package is the same type. The regression tests cover both PyTorch’s internal re-export and a user module that re-exports the public tensor alias, which documents that alias chains should resolve back to the canonical tensor identity.
Fixes #4062
Reviewed By: yangdanny97
Differential Revision: D111287027
fbshipit-source-id: 3a44a800b16da7beb0d2a1d31c5042ca4071d3ff1 parent 50ddd72 commit 4944790
2 files changed
Lines changed: 70 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3099 | 3099 | | |
3100 | 3100 | | |
3101 | 3101 | | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
3102 | 3108 | | |
3103 | | - | |
3104 | | - | |
| 3109 | + | |
| 3110 | + | |
3105 | 3111 | | |
3106 | 3112 | | |
3107 | 3113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
96 | 131 | | |
97 | 132 | | |
98 | 133 | | |
| |||
129 | 164 | | |
130 | 165 | | |
131 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
132 | 194 | | |
133 | 195 | | |
134 | 196 | | |
| |||
0 commit comments