Skip to main content

Module tensor

Module tensor 

Source
Expand description

A tensor handle: a descriptor and its buffers, paired structurally.

A tensor is a descriptor plus its buffers, and the C ABI used to make callers keep the two halves paired by convention — a consumer that fetched one without the other got either bytes it could not interpret or a description of bytes it did not have (#174). HurrayTensor owns both, so the pairing is structural: a caller holding the handle holds the description of the bytes it points at.

Every path that produces a tensor produces this handle (ADR-043): a stream read, a file read, and a native-protocol capsule, which carries one HurrayTensor * and no context. One destroy call, and its internal order cannot be got wrong.

§Reading one

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

§The owner

A producer’s buffers point into memory something else owns, and that something is passed in as an opaque owner pointer with an owner_release callback. This crate never interprets either, which is what lets hurray-python park a Python reference there without any Python type reaching the C ABI. A tensor from a read carries neither: it owns its buffers outright.

Structs§

HurrayTensor
Opaque handle to a tensor: its descriptor and its buffers.

Functions§

hurray_tensor_abi_version⚠
Reads the ABI version recorded by the producing build.
hurray_tensor_buffers⚠
Borrows the tensor’s buffer list.
hurray_tensor_descriptor⚠
Borrows the tensor’s descriptor handle.
hurray_tensor_destroy⚠
Destroys a tensor handle — its descriptor, every buffer it owns, and its owner reference — then writes null through handle.
hurray_tensor_new⚠
Creates a HurrayTensor from an encoded descriptor and a finished buffer list.

Type Aliases§

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