Commit 2842a83
authored
Improve DLPack support for external tensor consumption (#6261)
- Adds bulk DLPack TensorList constructors for lists of external tensors. The C++ path builds
CPU and GPU TensorLists in one pass after preflighting devices and peeking all capsule dtypes,
so dtype or device mismatches can fall back without partially consuming single-use capsules.
- Adds `ndd.Batch` fast paths for:
- lists of already evaluated `ndd.Tensor` objects, preserving storage, layout, dtype, enum
metadata, laziness behavior where applicable, and CUDA stream order;
- lists of external GPU tensors exposing DLPack, including stream-keyword handshakes and
same-device validation;
- lists of CPU and CUDA-host/pinned CPU DLPack tensors.
- Keeps requested dtype conversion on the existing slow path, so external DLPack capsules are not
consumed before conversion fallback.
- Improves `ndd.Tensor` DLPack ingestion:
- CPU read-only arrays that raise `BufferError` fall back to an explicit copy through the array
interface;
- GPU objects retry `__dlpack__()` without the `stream` keyword only when the producer rejects
the keyword, and fall back to `__cuda_array_interface__` only when DLPack is unavailable.
- Fixes mixed pinned/non-pinned non-contiguous GPU TensorLists. GPU sample sharing no longer
requires uniform `is_pinned()` state, which unblocks mixed-GPU batches where cross-device copies
use pinned staging memory. CPU TensorLists still enforce pinned-state compatibility.
- Makes `UserStream::GetStream(size_t dev)` public so the new bulk DLPack path can derive a
concrete per-device consumer stream.
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>1 parent 44419fa commit 2842a83
9 files changed
Lines changed: 757 additions & 75 deletions
File tree
- dali
- pipeline/data
- python
- nvidia/dali/experimental/dynamic
- test/python/experimental_mode
- util
- qa/TL0_multigpu
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
261 | | - | |
262 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
986 | | - | |
| 986 | + | |
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
992 | 991 | | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
993 | 998 | | |
994 | 999 | | |
995 | 1000 | | |
| |||
0 commit comments