pub struct Storage { /* private fields */ }Expand description
An owned, reference-counted buffer of elements on one device.
Storage is untyped at the buffer level — a flat byte buffer plus the
DType that says how to read it. Typed access is the business of the
backend that allocated it; nothing else may reinterpret the bytes.
Multiple tensors (views) may share one storage; storage never knows how
many.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn cpu_zeros(numel: usize, dtype: DType) -> Self
pub fn cpu_zeros(numel: usize, dtype: DType) -> Self
Allocate zero-initialized CPU storage for numel elements of
dtype.
Sourcepub fn cpu_from_bytes(bytes: Vec<u8>, dtype: DType) -> Self
pub fn cpu_from_bytes(bytes: Vec<u8>, dtype: DType) -> Self
Wrap raw host bytes as CPU storage. The byte length must be a multiple of the dtype size; the caller asserts the encoding.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
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