Skip to main content

Module tensor_context

Module tensor_context 

Source
Expand description

Opaque carrier for everything a native-protocol capsule holds beyond its buffers (ADR-034).

A capsule carries two things: its pointer is a HurrayBufferList, and its context is a HurrayTensorContext. The list holds the bytes; the context holds the encoded tensor descriptor that says what those bytes are — element type, shape, layout, quantization — plus the ABI version of the build that produced them.

Before ADR-034 the context was a Rust struct private to hurray-python, so only hurray-python could read it. The buffers crossed the language boundary and the descriptor did not, which made the protocol’s full-fidelity promise true between two Python peers and false for every other binding.

§Reading one

Check the version first, always — see hurray_tensor_context_abi_version. Every other accessor assumes a caller that has done so.

§The owner

A context keeps its producer’s tensor alive: the buffers point into memory something else owns. That something is passed in as an opaque owner pointer with an owner_release callback, and this crate never interprets either — which is what lets hurray-python park a Python reference there without any Python type reaching the C ABI.

Structs§

HurrayTensorContext
Opaque handle to a capsule’s tensor context: descriptor bytes, ABI version, and an owner reference.

Functions§

hurray_tensor_context_abi_version⚠
Reads the ABI version recorded by the producing build.
hurray_tensor_context_descriptor⚠
Borrows the encoded tensor descriptor.
hurray_tensor_context_destroy⚠
Destroys a HurrayTensorContext, invoking its owner-release callback, and nulls the caller’s pointer.
hurray_tensor_context_new⚠
Creates a HurrayTensorContext owning a copy of descriptor_bytes.

Type Aliases§

HurrayOwnerReleaseFn
Callback invoked exactly once by hurray_tensor_context_destroy to release whatever keeps the tensor’s memory alive.