Commit 16b6b0b
Fix modules ignoring default device when created via native P/Invoke (#1438)
MoveModule<T>() was returning modules unchanged when device=null, instead
of resolving to torch.get_default_device(). This caused Embedding,
EmbeddingBag, LSTM, GRU, RNN, LSTMCell, GRUCell, RNNCell, and PReLU to
always be created on CPU regardless of the default device setting.
Fix MoveModule to use GetDefaultDeviceAndType() to resolve defaults,
aligning behavior with managed modules like Linear and Conv2d.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 80291c7 commit 16b6b0b
2 files changed
Lines changed: 33 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
| 1141 | + | |
| 1142 | + | |
1145 | 1143 | | |
1146 | 1144 | | |
1147 | 1145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5264 | 5264 | | |
5265 | 5265 | | |
5266 | 5266 | | |
| 5267 | + | |
| 5268 | + | |
| 5269 | + | |
| 5270 | + | |
| 5271 | + | |
| 5272 | + | |
| 5273 | + | |
| 5274 | + | |
| 5275 | + | |
| 5276 | + | |
| 5277 | + | |
| 5278 | + | |
| 5279 | + | |
| 5280 | + | |
| 5281 | + | |
| 5282 | + | |
| 5283 | + | |
| 5284 | + | |
| 5285 | + | |
| 5286 | + | |
| 5287 | + | |
| 5288 | + | |
| 5289 | + | |
| 5290 | + | |
| 5291 | + | |
| 5292 | + | |
| 5293 | + | |
| 5294 | + | |
| 5295 | + | |
| 5296 | + | |
| 5297 | + | |
5267 | 5298 | | |
5268 | 5299 | | |
5269 | 5300 | | |
| |||
0 commit comments