Skip to main content

HurrayTensor

Struct HurrayTensor 

Source
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

Source

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
  • buffers MUST be a live list from hurray_buffer_list_new that nothing else owns; ownership transfers to the returned handle.
  • owner MUST remain valid until owner_release is invoked.
  • The returned pointer MUST be destroyed exactly once, with hurray_tensor_destroy.
Source

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.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.