pub enum Buffer {
Cpu(CpuBuffer),
}Expand description
The hardware-agnostic physical data container.
Variants§
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn new_cpu_zeros(size: usize, dtype: DType) -> Self
pub fn new_cpu_zeros(size: usize, dtype: DType) -> Self
Allocates a new contiguous CPU Buffer initialized with zeros.
Sourcepub fn from_f32_vec(data: Vec<f32>) -> Self
pub fn from_f32_vec(data: Vec<f32>) -> Self
Allocates a new CPU Buffer from an existing Vec of f32 data.
Sourcepub fn as_f32_slice(&self) -> EtensorResult<&[f32]>
pub fn as_f32_slice(&self) -> EtensorResult<&[f32]>
Safely extracts a reference to the underlying CPU f32 slice. Acts as an explicit boundary guard against DataType or Device mismatches.
Sourcepub fn strong_count(&self) -> EtensorResult<usize>
pub fn strong_count(&self) -> EtensorResult<usize>
Returns the active Arc pointer reference count for memory tracking.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more