pub struct HurrayTensor { /* private fields */ }Expand description
Opaque handle to a tensor: its descriptor and its buffers.
Not #[repr(C)]; the layout is an implementation detail. The handle owns both
halves. hurray_tensor_descriptor and hurray_tensor_buffers hand out borrowed
pointers — valid until hurray_tensor_destroy, and never to be destroyed
individually.
Implementations§
Source§impl HurrayTensor
impl HurrayTensor
Sourcepub unsafe fn from_core(
abi_version: u32,
descriptor: TensorDescriptor,
buffers: *mut HurrayBufferList,
owner: *mut c_void,
owner_release: HurrayOwnerReleaseFn,
) -> *mut HurrayTensor
pub unsafe fn from_core( abi_version: u32, descriptor: TensorDescriptor, buffers: *mut HurrayBufferList, owner: *mut c_void, owner_release: HurrayOwnerReleaseFn, ) -> *mut HurrayTensor
Builds a handle from an already-decoded descriptor, for a Rust producer.
The Rust-side twin of hurray_tensor_new, which decodes bytes a C caller
supplied. hurray-python holds a TensorDescriptor already, so encoding it only
for the constructor to decode it straight back would be a round trip through bytes
neither side wants (ADR-043).
§Safety
buffersMUST be a live list fromhurray_buffer_list_newthat nothing else owns; ownership transfers to the returned handle.ownerMUST remain valid untilowner_releaseis invoked.- The returned pointer MUST be destroyed exactly once, with
hurray_tensor_destroy.
Sourcepub fn core_descriptor(&self) -> Option<&TensorDescriptor>
pub fn core_descriptor(&self) -> Option<&TensorDescriptor>
Borrows the decoded descriptor as the hurray-core type, for a Rust consumer.
The Rust-side twin of hurray_tensor_descriptor, which hands a C caller the
opaque handle to read fields through. A Rust consumer — hurray-python rebuilding
its own tensor — wants the type itself, and re-encoding it to decode it again
would be the round trip HurrayTensor::from_core exists to avoid.
Returns None only for a handle mid-destruction, which a caller holding a live
tensor never has.