Repository navigation
Commit 02ad1e4
authored
Add a PyTorch to ExecuTorch device mapping (pytorch#21766)
The reverse mapping already exists in this header, and the scalar type conversions live
here as a matched pair in both directions. The direction that turns a PyTorch device
into an ExecuTorch one was missing, so a caller converting an incoming tensor had
nowhere to get it and had to write the two entry table itself.
Returns nothing for a device this runtime has no type for. That is a valid thing for a
caller to ask about, so it is reported rather than fatal, and the caller adds the
context it has, such as which input and which method, before failing. The opposite
direction aborts instead, because an unknown ExecuTorch device is an internal invariant
failure rather than something a user can cause.
Test Plan: extension/aten_util/test/aten_bridge_test.cpp gains two cases, mirroring the
pair that covers the opposite direction three lines above.
ReverseDeviceMapping CPU maps, CUDA maps, and the device
index is preserved
ReverseDeviceMappingReportsAnUnrepresentableDevice
a device with no runtime equivalent
reports rather than aborts
Neither needs an accelerator: only the mapping is under test, which is why the CUDA arm
and the index can be covered on a machine without one. Both were compiled and run
directly.
Worth knowing when reading this: the test directory here carries no CMake build file, so
these two cases are not compiled by the public continuous integration. They run in the
internal build and when run by hand. The behaviour they cover is also exercised indirectly
by the change above this one, which calls this mapping on every input.1 parent ff4cf27 commit 02ad1e4
3 files changed
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
153 | 167 | | |
154 | 168 | | |
155 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
35 | 46 | | |
36 | 47 | | |
37 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
322 | 346 | | |
323 | 347 | | |
324 | 348 | | |
| |||
0 commit comments