#[repr(C)]pub struct TensorDesc {}Expand description
The cross-package descriptor. Layout is part of the contract: it is
#[repr(C)] and its size is pinned by test.
Fields§
§version: u32ABI_VERSION. Checked, never assumed.
kind: u32One of the kind constants.
handle: i64dma-buf fd, IOSurface id, GL buffer id or D3D11 texture NT handle
value; -1 when unused.
ptr: SendPtrHost pointer when addressable, else null – except under
kind::PBO, where it instead carries a *const crate::pbo::PboOpsVtable, or null if the producer attached none,
and under kind::D3D11_TEXTURE, where it carries the process
device fence’s NT handle value, or null when Self::sync carries
nothing to wait on.
Interpretation is keyed by Self::kind, the same established
pattern Self::sync’s own doc comment already documents for that
field: a PBO tensor never takes a HostPin (PboTensor refuses
pin_host — the address cannot outlive the map), so this field is
otherwise permanently unused for that kind, which is exactly why it
is the field that carries the vtable instead of a new one requiring
a layout change. Valid under the exact same borrow contract as the
host-pointer case: only while the producer’s own keepalive (for the
capsule protocol, the capsule’s) keeps the owning tensor alive.
ndim: u32Number of significant entries in shape and strides.
dtype: u32Element type, one of the [dtype] constants.
Deliberately placed here: ndim leaves a 4-byte hole before the
8-aligned shape, so this field costs nothing. Without it strides
— documented in elements — cannot be converted to bytes by a
consumer, and a Tensor<f32> is indistinguishable from a
Tensor<u8> of the same shape.
shape: [u64; 8]Logical shape, most-significant dimension first.
strides: [i64; 8]Strides in bytes, signed so a consumer can express flips.
Bytes rather than elements so a hardware row pitch is always
representable: a pitch need not be a whole number of dtype elements
(and a sub-byte dtype has no element size to divide by). Multiply a
coordinate by the stride directly; do not scale by dtype size.
fourcc: u32DRM FourCC of the pixel format, or 0 for a non-image tensor. Kept for
third-party/DRM interop; a HAL-aware consumer should prefer
Self::format and fall back to this only when format is 0
(see format’s doc for why fourcc alone is insufficient).
format: u32One of the format constants, or 0 for a non-image tensor.
colorimetry: u32Packed colorimetry, or 0 when unspecified.
flags: u32Bit flags; see flags. Zero when nothing applies.
Occupies what was a 4-byte alignment hole before capacity, so it
cost nothing to add.
capacity: u64Bytes available in the producer’s underlying allocation, from this
tensor’s window start (its TensorTrait::capacity_bytes
) – may exceed the byte size
shape/strides imply when the producer over-allocated: a pool
tensor sized for its largest expected image but holding a smaller
one today, or row-pitch/MCU-alignment padding a decoder needs beyond
the logical width. Without this, a consumer importing a HOST
descriptor has no way to learn that headroom exists and must treat
the declared shape as the allocation’s exact size – which starves a
later configure_image/set_logical_shape of capacity the producer
actually has. DMABUF/IOSURFACE consumers query their real
capacity from the handle itself and do not depend on this field, but
it is populated for every kind for consistency.
sync: u64Completion handle for work still in flight against this tensor, or 0
when flags::SYNC_PRESENT is clear.
Filled in by kind::D3D11_TEXTURE producers, and left clear by
every other kind in this build. It was declared before any producer
set it because the field has to exist before the first release or
adding it later costs a capsule-name bump, and it is the one gap the
synchronous-at-the-boundary contract cannot close: a foreign
producer with queued GPU work has no other way to say “wait on this
first”.
Interpretation is keyed by Self::kind, since each backing already
implies its own fence flavour and a separate discriminant would be
redundant:
kind::DMABUF– async_filefd fromDMA_BUF_IOCTL_EXPORT_SYNC_FILE. The consumer owns it and must close it.kind::PBO– aGLsyncfromglFenceSync, valid only in the producer’s share group.kind::CUDA_DEVICE– acudaEvent_t.kind::D3D11_TEXTURE– a value on the timeline of theID3D11FenceSelf::ptrnames, not a handle of its own: the handle and the value together are what a consumer waits on.kind::HOST,kind::IOSURFACE– no fence flavour defined;SYNC_PRESENTmust be clear.
Implementations§
Source§impl TensorDesc
impl TensorDesc
Trait Implementations§
Source§impl Clone for TensorDesc
impl Clone for TensorDesc
impl Copy for TensorDesc
Auto Trait Implementations§
impl Freeze for TensorDesc
impl RefUnwindSafe for TensorDesc
impl Send for TensorDesc
impl Sync for TensorDesc
impl Unpin for TensorDesc
impl UnsafeUnpin for TensorDesc
impl UnwindSafe for TensorDesc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more