pub struct CudaSparseTensor {
pub format: SparseFormat,
pub device_id: i32,
pub dtype: DType,
pub shape: [usize; 2],
pub nnz: usize,
/* private fields */
}
Expand description
CUDA sparse tensor wrapper
Fields§
§format: SparseFormat
The sparse format used on GPU
device_id: i32
Device index
dtype: DType
Data type
shape: [usize; 2]
Shape of the tensor
nnz: usize
Number of non-zero elements
Implementations§
Source§impl CudaSparseTensor
impl CudaSparseTensor
Sourcepub fn from_coo(coo: &CooTensor, device_id: i32) -> TorshResult<Self>
pub fn from_coo(coo: &CooTensor, device_id: i32) -> TorshResult<Self>
Create a new CUDA sparse tensor from COO format
Sourcepub fn from_csr(csr: &CsrTensor, device_id: i32) -> TorshResult<Self>
pub fn from_csr(csr: &CsrTensor, device_id: i32) -> TorshResult<Self>
Create a new CUDA sparse tensor from CSR format
Sourcepub fn to_coo_gpu(&self) -> TorshResult<CudaSparseTensor>
pub fn to_coo_gpu(&self) -> TorshResult<CudaSparseTensor>
Convert to COO format on GPU
Sourcepub fn to_csr_gpu(&self) -> TorshResult<CudaSparseTensor>
pub fn to_csr_gpu(&self) -> TorshResult<CudaSparseTensor>
Convert to CSR format on GPU
Sourcepub fn spmm(&self, dense: &Tensor) -> TorshResult<Tensor>
pub fn spmm(&self, dense: &Tensor) -> TorshResult<Tensor>
Sparse matrix multiplication on GPU
Sourcepub fn spgemm(&self, other: &CudaSparseTensor) -> TorshResult<CudaSparseTensor>
pub fn spgemm(&self, other: &CudaSparseTensor) -> TorshResult<CudaSparseTensor>
Sparse matrix-sparse matrix multiplication on GPU
Sourcepub fn to_cpu(&self) -> TorshResult<CooTensor>
pub fn to_cpu(&self) -> TorshResult<CooTensor>
Copy tensor to CPU
Sourcepub fn is_cuda_available() -> bool
pub fn is_cuda_available() -> bool
Check if CUDA is available
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get device memory usage
Sourcepub fn format(&self) -> SparseFormat
pub fn format(&self) -> SparseFormat
Get sparse format
Trait Implementations§
Source§impl Clone for CudaSparseTensor
impl Clone for CudaSparseTensor
Source§fn clone(&self) -> CudaSparseTensor
fn clone(&self) -> CudaSparseTensor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CudaSparseTensor
impl RefUnwindSafe for CudaSparseTensor
impl Send for CudaSparseTensor
impl Sync for CudaSparseTensor
impl Unpin for CudaSparseTensor
impl UnwindSafe for CudaSparseTensor
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