CudaStorage

Enum CudaStorage 

Source
pub enum CudaStorage {
    F16(CudaSlice<u16>),
    BF16(CudaSlice<u16>),
    F32(CudaSlice<f32>),
    F64(CudaSlice<f64>),
    U8(CudaSlice<u8>),
    U32(CudaSlice<u32>),
    I64(CudaSlice<i64>),
}
Expand description

GPU-side storage. Each variant wraps a cudarc CudaSlice for the corresponding dtype. F16 and BF16 are stored as CudaSlice (bit-level representation).

Variants§

§

F16(CudaSlice<u16>)

§

BF16(CudaSlice<u16>)

§

F32(CudaSlice<f32>)

§

F64(CudaSlice<f64>)

§

U8(CudaSlice<u8>)

§

U32(CudaSlice<u32>)

§

I64(CudaSlice<i64>)

Implementations§

Source§

impl CudaStorage

Source

pub fn as_cuda_slice_f32(&self) -> Result<&CudaSlice<f32>>

Get the underlying CudaSlice (returns error if dtype doesn’t match).

Source

pub fn as_cuda_slice_u16(&self) -> Result<&CudaSlice<u16>>

Get the underlying CudaSlice for F16 or BF16 storage.

Source

pub fn from_f32_vec(data: Vec<f32>, device: &CudaDevice) -> Result<Self>

Transfer data from host Vec to a new CudaStorage on the given device.

Source

pub fn from_f64_vec(data: Vec<f64>, device: &CudaDevice) -> Result<Self>

Transfer data from host Vec to a new CudaStorage on the given device.

Source

pub fn from_f16_vec(data: Vec<f16>, device: &CudaDevice) -> Result<Self>

Transfer data from host Vec to a new F16 CudaStorage on the given device.

Source

pub fn from_bf16_vec(data: Vec<bf16>, device: &CudaDevice) -> Result<Self>

Transfer data from host Vec to a new BF16 CudaStorage on the given device.

Source

pub fn to_host_f64(&self, device: &CudaDevice) -> Result<Vec<f64>>

Copy all data to host as Vec.

Trait Implementations§

Source§

impl BackendStorage for CudaStorage

Source§

fn dtype(&self) -> DType

The data type of the elements in this storage.
Source§

fn len(&self) -> usize

Total number of elements that fit in this storage.
§

fn is_empty(&self) -> bool

Source§

impl Clone for CudaStorage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CudaStorage

Source§

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

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

impl Send for CudaStorage

Source§

impl Sync for CudaStorage

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V