Skip to main content

TensorBuffer

Struct TensorBuffer 

Source
pub struct TensorBuffer { /* private fields */ }
Expand description

Owned host allocation paired with a validated tensor descriptor.

Implementations§

Source§

impl TensorBuffer

Source

pub fn try_new( bytes: Vec<u8>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and takes ownership of a host allocation.

Source

pub fn try_from_u16( values: Vec<u16>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned u16 storage without byte repacking.

Source

pub fn try_from_i16( values: Vec<i16>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned i16 storage without byte repacking.

Source

pub fn try_from_u32( values: Vec<u32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned u32 storage without byte repacking.

Source

pub fn try_from_i32( values: Vec<i32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned i32 storage without byte repacking.

Source

pub fn try_from_i64( values: Vec<i64>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned i64 storage without byte repacking.

Source

pub fn try_from_f32( values: Vec<f32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned f32 storage without byte repacking.

Source

pub fn try_from_f64( values: Vec<f64>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and owns aligned f64 storage without byte repacking.

Source

pub fn try_from_host_storage( storage: Arc<dyn HostTensorStorage>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>

Validates and retains a runtime-owned host allocation without copying it.

Source

pub fn view(&self) -> TensorView<'_>

Returns a zero-copy borrowed view.

Source

pub const fn descriptor(&self) -> &TensorDescriptor

Returns tensor metadata.

Source

pub fn allocation_bytes(&self) -> &[u8]

Returns the complete owned allocation bytes.

Source

pub fn to_owned_copy(&self) -> Self

Performs an explicit host-to-host copy while preserving typed alignment.

Source

pub fn shared_f32(&self) -> Option<Arc<[f32]>>

Returns shared aligned f32 storage when constructed with Self::try_from_f32.

Source

pub fn shared_bytes(&self) -> Option<Arc<[u8]>>

Returns shared byte storage when constructed with Self::try_new.

This is suitable for zero-copy u8 and i8 tensor adapters. Multi-byte element types must use their matching typed constructor and accessor.

Source

pub fn shared_f64(&self) -> Option<Arc<[f64]>>

Returns shared aligned f64 storage when constructed with Self::try_from_f64.

Source

pub fn shared_i16(&self) -> Option<Arc<[i16]>>

Returns shared aligned i16 storage when constructed with Self::try_from_i16.

Source

pub fn shared_i32(&self) -> Option<Arc<[i32]>>

Returns shared aligned i32 storage when constructed with Self::try_from_i32.

Source

pub fn shared_i64(&self) -> Option<Arc<[i64]>>

Returns shared aligned i64 storage when constructed with Self::try_from_i64.

Source

pub fn shared_u16(&self) -> Option<Arc<[u16]>>

Returns shared aligned u16 storage when constructed with Self::try_from_u16.

Source

pub fn shared_u32(&self) -> Option<Arc<[u32]>>

Returns shared aligned u32 storage when constructed with Self::try_from_u32.

Source

pub fn host_storage(&self) -> Option<&Arc<dyn HostTensorStorage>>

Returns runtime-owned host storage, when this tensor wraps one.

Source

pub const fn ownership(&self) -> Ownership

Reports owned storage.

Source

pub fn into_allocation_bytes_copy(self) -> (Vec<u8>, TensorDescriptor)

Explicitly copies the allocation into bytes and returns its metadata.

Trait Implementations§

Source§

impl Clone for TensorBuffer

Source§

fn clone(&self) -> TensorBuffer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TensorBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TensorBuffer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TensorBuffer

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.