Skip to main content

SparseMatrixDescriptor

Struct SparseMatrixDescriptor 

Source
pub struct SparseMatrixDescriptor<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> SparseMatrixDescriptor<'a>

Source

pub fn create_csr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, row_offsets: &'a mut DeviceMemory<Offsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>

Initializes a sparse matrix descriptor in the CSR format.

The descriptor borrows the row-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn create_csc<Offsets: IndexTypeLike, Rows: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, column_offsets: &'a mut DeviceMemory<Offsets>, row_indices: &'a mut DeviceMemory<Rows>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>

Initializes a sparse matrix descriptor in the CSC format.

The descriptor borrows the column-offset, row-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn create_coo<I: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, row_indices: &'a mut DeviceMemory<I>, column_indices: &'a mut DeviceMemory<I>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>

Initializes a sparse matrix descriptor in the COO format (Structure of Arrays layout).

The descriptor borrows the row-index, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn create_bsr<Offsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, block_rows: usize, block_cols: usize, block_nnz: usize, row_block_size: usize, col_block_size: usize, row_offsets: &'a mut DeviceMemory<Offsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, order: Order, ) -> Result<Self>

Initializes a sparse matrix descriptor for the Block Compressed Row (BSR) format.

The descriptor borrows the block row-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn create_blocked_ell<I: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, block_size: usize, ell_cols: usize, column_indices: &'a mut DeviceMemory<I>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>

Initializes a sparse matrix descriptor for the Blocked-Ellpack (ELL) format.

Blocked-ELL column indices are in the range 0..cols / ell_block_size. The array can contain -1 values for indicating empty blocks. The descriptor borrows the column-index and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn create_sliced_ell<SliceOffsets: IndexTypeLike, Columns: IndexTypeLike, T: DataTypeLike>( ctx: &Context, rows: usize, cols: usize, nonzero_count: usize, values_size: usize, slice_size: usize, slice_offsets: &'a mut DeviceMemory<SliceOffsets>, column_indices: &'a mut DeviceMemory<Columns>, values: &'a mut DeviceMemory<T>, index_base: IndexBase, ) -> Result<Self>

Initializes a sparse matrix descriptor for the Sliced Ellpack (SELL) format.

The descriptor borrows the slice-offset, column-index, and value buffers by pointer; those buffers must remain valid while the descriptor uses them.

Source

pub fn format(&self) -> Result<Format>

Returns the format of this sparse matrix descriptor.

§Errors

Returns an error if cuSPARSE cannot report the sparse matrix format.

Source

pub fn index_base(&self) -> Result<IndexBase>

Returns the index base of this sparse matrix descriptor.

§Errors

Returns an error if cuSPARSE cannot report the sparse matrix index base.

Source

pub fn values(&self) -> Result<DevicePtr>

Returns the values pointer of this sparse matrix descriptor.

§Errors

Returns an error if cuSPARSE cannot report the values pointer.

Source

pub fn set_values<T: DataTypeLike>( &mut self, values: &'a mut DeviceMemory<T>, ) -> Result<()>

Sets the values pointer of this sparse matrix descriptor.

The pointed-to device buffer must remain valid while the descriptor uses it.

§Errors

Returns an error if cuSPARSE rejects the values pointer.

Source

pub fn shape(&self) -> Result<SparseMatrixShape>

Returns the shape of this sparse matrix descriptor.

§Errors

Returns an error if cuSPARSE cannot report the sparse matrix shape or if the reported values cannot be represented as usize.

Source

pub fn strided_batch_count(&self) -> Result<i32>

Returns the batch count of this sparse matrix descriptor.

§Errors

Returns an error if cuSPARSE cannot report the strided batch settings.

Source

pub fn set_coo_strided_batch( &mut self, batch_count: usize, batch_stride: usize, ) -> Result<()>

Sets the batch count and batch stride fields of this COO sparse matrix descriptor.

§Errors

Returns an error if either argument cannot be represented by cuSPARSE or if cuSPARSE rejects the strided batch settings.

Source

pub fn set_csr_strided_batch( &mut self, batch_count: usize, offsets_batch_stride: usize, columns_values_batch_stride: usize, ) -> Result<()>

Sets the batch count and batch stride fields of this CSR sparse matrix descriptor.

Source

pub fn set_bsr_strided_batch( &mut self, batch_count: usize, offsets_batch_stride: usize, columns_batch_stride: usize, values_batch_stride: usize, ) -> Result<()>

Sets the batch count and batch stride fields of this BSR sparse matrix descriptor.

Source

pub fn fill_mode(&self) -> Result<FillMode>

Source

pub fn set_fill_mode(&mut self, fill_mode: FillMode) -> Result<()>

Source

pub fn diagonal_type(&self) -> Result<DiagonalType>

Source

pub fn set_diagonal_type(&mut self, diagonal_type: DiagonalType) -> Result<()>

Source

pub fn set_csr_pointers( &mut self, row_offsets: &'a mut DeviceMemory<impl IndexTypeLike>, column_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>

Sets the pointers of this CSR sparse matrix descriptor.

The pointed-to device buffers must remain valid while the descriptor uses them.

Source

pub fn set_csc_pointers( &mut self, column_offsets: &'a mut DeviceMemory<impl IndexTypeLike>, row_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>

Sets the pointers of this CSC sparse matrix descriptor.

The pointed-to device buffers must remain valid while the descriptor uses them.

Source

pub fn set_coo_pointers( &mut self, row_indices: &'a mut DeviceMemory<impl IndexTypeLike>, column_indices: &'a mut DeviceMemory<impl IndexTypeLike>, values: &'a mut DeviceMemory<impl DataTypeLike>, ) -> Result<()>

Sets the pointers of this COO sparse matrix descriptor.

The pointed-to device buffers must remain valid while the descriptor uses them.

Source

pub fn as_raw(&self) -> cusparseSpMatDescr_t

Source

pub fn as_raw_const(&self) -> cusparseConstSpMatDescr_t

Source

pub fn cuda_context(&self) -> &Arc<CudaContext>

Source

pub unsafe fn from_raw( handle: cusparseSpMatDescr_t, ctx: &Context, ) -> Result<Self>

Wraps an existing cuSPARSE sparse-matrix descriptor and takes ownership of it.

§Safety

handle must be a valid cusparseSpMatDescr_t. Any device buffers referenced by the descriptor must remain valid for lifetime 'a. Ownership of handle is transferred to the returned descriptor, and the handle must not be destroyed elsewhere after calling this function.

Source

pub fn into_raw(self) -> cusparseSpMatDescr_t

Consumes the descriptor and returns the raw cuSPARSE handle without destroying it.

The caller becomes responsible for eventually destroying the returned handle with cusparseDestroySpMat.

Trait Implementations§

Source§

impl<'a> Debug for SparseMatrixDescriptor<'a>

Source§

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

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

impl Drop for SparseMatrixDescriptor<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for SparseMatrixDescriptor<'_>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.