Skip to main content

export

Function export 

Source
pub fn export(
    t: &TensorDyn,
    mode: TransportMode,
) -> Result<(Vec<u8>, Vec<RawFd>)>
Expand description

Serialize a tensor to a blob in the requested transport mode.

Returns the blob and its fd table. The two travel together and are meaningless apart: a plane’s handle is an index into the table, because a raw fd number does not survive a process boundary.

Export borrows and performs no syscalls. In TransportMode::Reference the fds in the table are the source tensor’s own, valid only while it lives; dup happens on import, never here. That is what makes export cheap and removes any keepalive protocol between producer and consumer.

On Windows the table is empty and each plane carries D3D11_HANDLE_BYTES instead: the texture’s NT handle value, the process device fence’s, and the last recorded GPU write. Those are borrowed on the same terms – they are handle-table entries of this process, which the header’s pid is what lets an importer reach.