1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Conversion from externally supplied DLPack tensors.
/// Fallible conversion from an externally supplied DLPack tensor.
///
/// Implementations validate representable descriptor values such as device,
/// dtype, shape, and strides. They cannot validate whether foreign pointers
/// are readable or whether the producer still accesses the underlying data.
///
/// # Stream synchronization
///
/// The `S` parameter carries the producer's stream handle so device-tensor
/// consumers can synchronize without a blocking host call: implementations
/// record a wait on their own stream for the producer's outstanding work
/// (e.g. `consumer_stream.join(producer_stream)` for cudarc). It is *not* the
/// consumer's own stream — the consumer creates that internally — and it is
/// *not* the Python `__dlpack__(stream=)` argument, which flows the other
/// direction and is handled by the [`crate::python`] layer. `S = ()` means no
/// producer stream is available: device-tensor consumers then leave
/// cross-stream synchronization to the caller, while CPU consumers ignore it.