pub struct TensorBuffer { /* private fields */ }Expand description
Owned host allocation paired with a validated tensor descriptor.
Implementations§
Source§impl TensorBuffer
impl TensorBuffer
Sourcepub fn try_new(
bytes: Vec<u8>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_new( bytes: Vec<u8>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and takes ownership of a host allocation.
Sourcepub fn try_from_u16(
values: Vec<u16>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_u16( values: Vec<u16>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned u16 storage without byte repacking.
Sourcepub fn try_from_i16(
values: Vec<i16>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_i16( values: Vec<i16>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned i16 storage without byte repacking.
Sourcepub fn try_from_u32(
values: Vec<u32>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_u32( values: Vec<u32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned u32 storage without byte repacking.
Sourcepub fn try_from_i32(
values: Vec<i32>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_i32( values: Vec<i32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned i32 storage without byte repacking.
Sourcepub fn try_from_i64(
values: Vec<i64>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_i64( values: Vec<i64>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned i64 storage without byte repacking.
Sourcepub fn try_from_f32(
values: Vec<f32>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_f32( values: Vec<f32>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned f32 storage without byte repacking.
Sourcepub fn try_from_f64(
values: Vec<f64>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
pub fn try_from_f64( values: Vec<f64>, descriptor: TensorDescriptor, ) -> Result<Self, TensorError>
Validates and owns aligned f64 storage without byte repacking.
Sourcepub fn try_from_host_storage(
storage: Arc<dyn HostTensorStorage>,
descriptor: TensorDescriptor,
) -> Result<Self, TensorError>
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.
Sourcepub fn view(&self) -> TensorView<'_>
pub fn view(&self) -> TensorView<'_>
Returns a zero-copy borrowed view.
Sourcepub const fn descriptor(&self) -> &TensorDescriptor
pub const fn descriptor(&self) -> &TensorDescriptor
Returns tensor metadata.
Sourcepub fn allocation_bytes(&self) -> &[u8] ⓘ
pub fn allocation_bytes(&self) -> &[u8] ⓘ
Returns the complete owned allocation bytes.
Sourcepub fn to_owned_copy(&self) -> Self
pub fn to_owned_copy(&self) -> Self
Performs an explicit host-to-host copy while preserving typed alignment.
Returns shared aligned f32 storage when constructed with Self::try_from_f32.
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.
Returns shared aligned f64 storage when constructed with Self::try_from_f64.
Returns shared aligned i16 storage when constructed with Self::try_from_i16.
Returns shared aligned i32 storage when constructed with Self::try_from_i32.
Returns shared aligned i64 storage when constructed with Self::try_from_i64.
Returns shared aligned u16 storage when constructed with Self::try_from_u16.
Returns shared aligned u32 storage when constructed with Self::try_from_u32.
Sourcepub fn host_storage(&self) -> Option<&Arc<dyn HostTensorStorage>>
pub fn host_storage(&self) -> Option<&Arc<dyn HostTensorStorage>>
Returns runtime-owned host storage, when this tensor wraps one.
Sourcepub fn into_allocation_bytes_copy(self) -> (Vec<u8>, TensorDescriptor)
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
impl Clone for TensorBuffer
Source§fn clone(&self) -> TensorBuffer
fn clone(&self) -> TensorBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more