pub struct Storage { /* private fields */ }Expand description
An owned, reference-counted buffer of elements on one device.
Multiple tensors (views) may share one storage; storage never knows how many.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn cpu_f32_zeros(numel: usize) -> Self
pub fn cpu_f32_zeros(numel: usize) -> Self
Zero-initialized CPU storage for numel f32 elements.
Sourcepub fn from_f32_vec(data: Vec<f32>) -> Self
pub fn from_f32_vec(data: Vec<f32>) -> Self
CPU storage owning data as f32 elements.
Sourcepub fn from_f64_vec(data: Vec<f64>) -> Self
pub fn from_f64_vec(data: Vec<f64>) -> Self
CPU storage owning data as f64 elements.
Sourcepub fn from_i64_vec(data: Vec<i64>) -> Self
pub fn from_i64_vec(data: Vec<i64>) -> Self
CPU storage owning data as i64 elements.
Sourcepub fn data(&self) -> &StorageData
pub fn data(&self) -> &StorageData
The raw storage data.
Sourcepub fn cpu(&self) -> Result<&CpuStorage>
pub fn cpu(&self) -> Result<&CpuStorage>
The typed CPU buffer, or a typed error when the storage is on a different device.
Sourcepub fn from_opaque(buffer: OpaqueBuffer, dtype: DType, device: Device) -> Self
pub fn from_opaque(buffer: OpaqueBuffer, dtype: DType, device: Device) -> Self
Storage backed by an out-of-tree backend’s allocation.
Sourcepub fn opaque(&self) -> Option<&OpaqueBuffer>
pub fn opaque(&self) -> Option<&OpaqueBuffer>
The opaque buffer, when this storage lives on an out-of-tree backend.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Storage
impl !UnwindSafe for Storage
impl Freeze for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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