Expand description
Zero-copy device tensor views (§5.4) and their DLPack alignment (§5.3).
These are thin, non-owning views over device-resident memory used at the kernel boundary. They intentionally use raw device pointers; the owning session/EP guarantees the backing memory outlives the view.
§DLPack correspondence (§5.3)
A TensorView carries exactly the fields a DLPack DLTensor needs to be
reconstructed, so import/export is a field-wise mapping rather than a copy:
DLTensor | TensorView |
|---|---|
data | TensorView::data |
byte_offset | TensorView::byte_offset |
shape / ndim | TensorView::shape |
strides (elements) | TensorView::strides |
device | TensorView::device |
dtype | TensorView::dtype |
DLPack keeps byte_offset separate from data (the base pointer is the
allocation start; byte_offset selects the element origin) and permits
negative strides. Both are representable here: strides are i64 and the
offset is applied lazily by TensorView::data_ptr. Use
TensorView::validate to check the invariants of an imported view before
handing it to a kernel.
Structs§
- Device
Ptr - An opaque immutable device pointer (a host pointer for CPU tensors).
- Device
PtrMut - An opaque mutable device pointer.
- Tensor
Mut - Mutable, non-owning view of a tensor on any device.
- Tensor
View - Immutable, non-owning view of a tensor on any device.