Skip to main content

Module tensor

Module tensor 

Source
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:

DLTensorTensorView
dataTensorView::data
byte_offsetTensorView::byte_offset
shape / ndimTensorView::shape
strides (elements)TensorView::strides
deviceTensorView::device
dtypeTensorView::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§

DevicePtr
An opaque immutable device pointer (a host pointer for CPU tensors).
DevicePtrMut
An opaque mutable device pointer.
ExternalMmapRegion
One validated read-only range in an ONNX external-data mmap.
TensorMut
Mutable, non-owning view of a tensor on any device.
TensorView
Immutable, non-owning view of a tensor on any device.

Enums§

TensorBacking
Provenance relevant to kernels that can consume lazy external weights.