Commit b5ec10d
Add strided layout guard to tensor bridge, reject sparse tensors
Check aoti_torch_get_layout() before extracting metadata — reject
non-strided tensors (sparse, mkldnn, etc.) whose shape/strides are
not meaningful for dense memory access.
We intentionally skip the other Python-level __dlpack__ guards
(requires_grad, is_conj, is_neg, wrong-device) for the same reason
PyTorch's own __dlpack_c_exchange_api__ C path skips them: the
C-level exchange path is designed for performance-critical consumers.
PyTorch's DLTensorFromPyObjectNoSync → toDLPackNonOwning performs
zero safety checks (see aten/src/ATen/DLConvertor.cpp).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 615f984 commit b5ec10d
3 files changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
310 | 315 | | |
311 | 316 | | |
312 | 317 | | |
| 318 | + | |
313 | 319 | | |
314 | 320 | | |
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
318 | 338 | | |
319 | 339 | | |
320 | 340 | | |
| |||
0 commit comments