hipSPARSELt API reference

Contents

hipSPARSELt API reference#

hipsparseLtGetVersion()#

hipsparseStatus_t hipsparseLtGetVersion(const hipsparseLtHandle_t *handle, int *version)#

Retrieve the version number of the hipSPARSELt library.

hipsparseLtGetVersion returns the version number of the hipSPARSELt library.

Parameters:
  • handle[in] hipsparselt library handle.

  • version[out] the version number of the library.

Return values:
  • HIPSPARSE_STATUS_SUCCESS

  • HIPSPARSE_STATUS_INVALID_VALUE – the handle is invalid.

hipsparseLtGetProperty()#

hipsparseStatus_t hipsparseLtGetProperty(hipLibraryPropertyType propertyType, int *value)#

Retrieve the value of the requested property.

hipsparseLtGetProperty returns the value of the requested property.

Parameters:
  • propertyType[in] hipLibraryPropertyType property type (as defined in library_types.h).

  • value[out] value of the requested property.

Return values:

HIPSPARSE_STATUS_SUCCESS

hipsparseLtInit()#

hipsparseStatus_t hipsparseLtInit(hipsparseLtHandle_t *handle)#

Create a hipSPARSELt handle.

hipsparseLtInit creates the hipSPARSELt library context. It must be initialized before any other hipSPARSELt API function is invoked and must be passed to all subsequent library function calls. The handle should be destroyed at the end using hipsparseLtDestroy_handle().

Parameters:

handle[out] hipsparselt library handle.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the initialization succeeded.

  • HIPSPARSE_STATUS_INVALID_VALUE – the handle is invalid.

hipsparseLtDestroy()#

hipsparseStatus_t hipsparseLtDestroy(const hipsparseLtHandle_t *handle)#

Destroy a hipSPARSELt handle.

hipsparseLtDestroy destroys the hipSPARSELt library context and releases all resources used by the hipSPARSELt library.

Parameters:

handle[in] hipsparselt library handle

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_NOT_INITIALIZED – the handle is invalid.

hipsparseLtDenseDescriptorInit()#

hipsparseStatus_t hipsparseLtDenseDescriptorInit(const hipsparseLtHandle_t *handle, hipsparseLtMatDescriptor_t *matDescr, int64_t rows, int64_t cols, int64_t ld, uint32_t alignment, hipDataType valueType, hipsparseOrder_t order)#

Create a descriptor for a dense matrix.

hipsparseLtDenseDescriptorInit creates and initializes a matrix descriptor. It should be destroyed at the end using hipsparseLtMatDescriptorDestroy().

Parameters:
  • handle[in] the hipsparselt handle.

  • matDescr[out] the pointer to the dense matrix descriptor.

  • rows[in] number of rows.

  • cols[in] number of columns.

  • ld[in] leading dimension.

  • alignment[in] memory alignment in bytes (not used by the HIP backend).

  • valueType[in] data type of the matrix. See hipDataType.

  • order[in] memory layout: HIPSPARSE_ORDER_COL or HIPSPARSE_ORDER_ROW.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, descr, rows, cols, or ld is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDrows, cols, ld, alignment, valueType, or order is not supported.

hipsparseLtStructuredDescriptorInit()#

hipsparseStatus_t hipsparseLtStructuredDescriptorInit(const hipsparseLtHandle_t *handle, hipsparseLtMatDescriptor_t *matDescr, int64_t rows, int64_t cols, int64_t ld, uint32_t alignment, hipDataType valueType, hipsparseOrder_t order, hipsparseLtSparsity_t sparsity)#

Create a descriptor for a structured matrix.

hipsparseLtStructuredDescriptorInit creates and initializes a matrix descriptor. It should be destroyed at the end using hipsparseLtMatDescriptorDestroy().

Parameters:
  • handle[in] the hipsparselt handle.

  • matDescr[out] the pointer to the dense matrix descriptor.

  • rows[in] number of rows.

  • cols[in] number of columns.

  • ld[in] leading dimension.

  • alignment[in] memory alignment in bytes (not used by the HIP backend).

  • valueType[in] data type of the matrix. See hipDataType.

  • order[in] memory layout: HIPSPARSE_ORDER_COL or HIPSPARSE_ORDER_ROW.

  • sparsity[in] matrix sparsity ratio. See hipsparseLtSparsity_t.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, descr, rows, cols, or ld is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDrows, cols, ld, alignment, valueType, or order is not supported.

hipsparseLtMatDescriptorDestroy()#

hipsparseStatus_t hipsparseLtMatDescriptorDestroy(const hipsparseLtMatDescriptor_t *matDescr)#

Destroy a matrix descriptor.

hipsparseLtMatDescriptorDestroy destroys a matrix descriptor and releases all resources used by the descriptor.

Parameters:

matDescr[in] the matrix descriptor.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEdescr is invalid.

hipsparseLtMatDescSetAttribute()#

hipsparseStatus_t hipsparseLtMatDescSetAttribute(const hipsparseLtHandle_t *handle, hipsparseLtMatDescriptor_t *matDescr, hipsparseLtMatDescAttribute_t matAttribute, const void *data, size_t dataSize)#

Specify the matrix attribute of a matrix descriptor.

hipsparseLtMatDescSetAttribute sets the value of the specified attribute belonging to a matrix descriptor, such as number of batches and their stride.

Parameters:
  • handle[in] the hipsparselt handle.

  • matDescr[inout] the matrix descriptor.

  • matAttribute[in] HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE.

  • data[in] pointer to the value to which the specified attribute will be set.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matmulDescr, data, or dataSize is invalid.

hipsparseLtMatDescGetAttribute()#

hipsparseStatus_t hipsparseLtMatDescGetAttribute(const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *matDescr, hipsparseLtMatDescAttribute_t matAttribute, void *data, size_t dataSize)#

Get the matrix type of a matrix descriptor.

hipsparseLtMatDescGetAttribute returns the matrix attribute of a matrix descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • matDescr[in] the matrix descriptor.

  • matAttribute[in] HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE.

  • data[inout] the memory address containing the attribute value retrieved by this function.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, descr, data, or dataSize is invalid.

hipsparseLtMatmulDescriptorInit()#

hipsparseStatus_t hipsparseLtMatmulDescriptorInit(const hipsparseLtHandle_t *handle, hipsparseLtMatmulDescriptor_t *matmulDescr, hipsparseOperation_t opA, hipsparseOperation_t opB, const hipsparseLtMatDescriptor_t *matA, const hipsparseLtMatDescriptor_t *matB, const hipsparseLtMatDescriptor_t *matC, const hipsparseLtMatDescriptor_t *matD, hipsparseLtComputetype_t computeType)#

Initializes the matrix multiplication descriptor.

hipsparseLtMatmulDescriptorInit creates a matrix multiplication descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • matmulDescr[inout] the matrix multiplication descriptor.

  • opA[in] hipsparse operation for Matrix A: HIPSPARSE_OPERATION_NON_TRANSPOSE or HIPSPARSE_OPERATION_TRANSPOSE.

  • opB[in] hipsparse operation for Matrix B: HIPSPARSE_OPERATION_NON_TRANSPOSE or HIPSPARSE_OPERATION_TRANSPOSE.

  • matA[in] the matrix descriptor (one and only one of matA or matB is a structured sparsity matrix).

  • matB[in] the matrix descriptor (one and only one of matA or matB is a structured sparsity matrix).

  • matC[in] the matrix descriptor (dense matrix).

  • matD[in] the matrix descriptor (dense matrix).

  • computeType[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matmulDescr, opA, opB, matA, matB, matC, matD, or computeType is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDopA, opB, or computeType is invalid.

hipsparseLtMatmulDescSetAttribute()#

hipsparseStatus_t hipsparseLtMatmulDescSetAttribute(const hipsparseLtHandle_t *handle, hipsparseLtMatmulDescriptor_t *matmulDescr, hipsparseLtMatmulDescAttribute_t matmulAttribute, const void *data, size_t dataSize)#

Specify the matrix attribute of a matrix descriptor.

hipsparseLtMatmulDescSetAttribute sets the value of the specified attribute belonging to a matrix descriptor, such as number of batches and their stride.

Parameters:
  • handle[in] the hipsparselt handle.

  • matmulDescr[inout] the matrix multiplication descriptor.

  • matmulAttribute[in] see hipsparseLtMatmulDescAttribute_t.

  • data[in] pointer to the value to which the specified attribute will be set.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matDescr, data, or dataSize is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDhipsparseLtMatmulDescAttribute_t is not supported.

hipsparseLtMatmulDescGetAttribute()#

hipsparseStatus_t hipsparseLtMatmulDescGetAttribute(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulDescriptor_t *matmulDescr, hipsparseLtMatmulDescAttribute_t matmulAttribute, void *data, size_t dataSize)#

Get the matrix type of a matrix descriptor.

hipsparseLtMatmulDescGetAttribute returns the matrix attribute of a matrix descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • matmulDescr[in] the matrix multiplication descriptor.

  • matmulAttribute[in] see hipsparseLtMatmulDescAttribute_t.

  • data[inout] the memory address containing the attribute value retrieved by this function.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matDescr, data, or dataSize is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDhipsparseLtMatmulDescAttribute_t is not supported.

hipsparseLtMatmulAlgSelectionInit()#

hipsparseStatus_t hipsparseLtMatmulAlgSelectionInit(const hipsparseLtHandle_t *handle, hipsparseLtMatmulAlgSelection_t *algSelection, const hipsparseLtMatmulDescriptor_t *matmulDescr, hipsparseLtMatmulAlg_t alg)#

Initializes the algorithm selection descriptor.

hipsparseLtMatmulAlgSelectionInit creates a algorithm selection descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • algSelection[out] the pointer to the algorithm selection descriptor.

  • matmulDescr[in] the matrix multiplication descriptor.

  • alg[in] the algorithm used to perform the matrix multiplication.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matmulDescr, or algSelection is invalid.

hipsparseLtMatmulAlgSelectionDestroy()#

hipsparseStatus_t hipsparseLtMatmulAlgSelectionDestroy(const hipsparseLtMatmulAlgSelection_t *algSelection)#

Destroy the algorithm selection descriptor.

hipsparseLtMatmulAlgSelectionDestroy releases the resources used by an instance of the algorithm selection. This function is the last call with a specific algorithm selection instance.

Parameters:

algSelection[in] the algorithm selection descriptor

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEalgSelection is invalid.

hipsparseLtMatmulAlgSetAttribute()#

hipsparseStatus_t hipsparseLtMatmulAlgSetAttribute(const hipsparseLtHandle_t *handle, hipsparseLtMatmulAlgSelection_t *algSelection, hipsparseLtMatmulAlgAttribute_t attribute, const void *data, size_t dataSize)#

Specify the algorithm attribute of a algorithm selection descriptor.

hipsparseLtMatmulAlgSetAttribute sets the value of the specified attribute belonging to a algorithm selection descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • algSelection[inout] the algorithm selection descriptor.

  • attribute[in] attributes are specified in hipsparseLtMatmulAlgAttribute_t.

  • data[in] pointer to the value to which the specified attribute will be set.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, algSelection, attribute, data, or dataSize is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDattribute is not supported.

hipsparseLtMatmulAlgGetAttribute()#

hipsparseStatus_t hipsparseLtMatmulAlgGetAttribute(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulAlgSelection_t *algSelection, hipsparseLtMatmulAlgAttribute_t attribute, void *data, size_t dataSize)#

Get the specific algorithm attribute from the algorithm selection descriptor.

hipsparseLtMatmulAlgGetAttribute returns the value of the queried attribute belonging to the algorithm selection descriptor.

Parameters:
  • handle[in] the hipsparselt handle.

  • algSelection[in] the algorithm selection descriptor.

  • attribute[in] attributes are specified in hipsparseLtMatmulAlgAttribute_t.

  • data[inout] the memory address containing the attribute value retrieved by this function.

  • dataSize[in] size in bytes of the attribute value used for verification.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, algSelection, attribute, data, or dataSize is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTEDattribute is not supported.

hipsparseLtMatmulGetWorkspace()#

hipsparseStatus_t hipsparseLtMatmulGetWorkspace(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, size_t *workspaceSize)#

Determines the required workspace size.

hipsparseLtMatmulGetWorkspace determines the required workspace size associated with the selected algorithm.

Parameters:
  • handle[in] hipsparselt library handle.

  • plan[in] the matrix multiplication plan descriptor.

  • workspaceSize[out] workspace size in bytes.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, algSelection, or workspaceSize is invalid.

hipsparseLtMatmulPlanInit()#

hipsparseStatus_t hipsparseLtMatmulPlanInit(const hipsparseLtHandle_t *handle, hipsparseLtMatmulPlan_t *plan, const hipsparseLtMatmulDescriptor_t *matmulDescr, const hipsparseLtMatmulAlgSelection_t *algSelection)#

Initializes the matrix multiplication plan descriptor.

hipsparseLtMatmulPlanInit creates a matrix multiplication plan descriptor. It should be destroyed at the end using hipsparseLtMatmulPlanDestroy.

Parameters:
  • handle[in] hipsparselt library handle.

  • plan[out] the matrix multiplication plan descriptor.

  • matmulDescr[in] the matrix multiplication descriptor.

  • algSelection[in] the algorithm selection descriptor.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, plan, matmulDescr, algSelection, or workspaceSize is invalid. HIPSPARSELT_MAT_NUM_BATCHES from matrix A to D are inconsistent.

hipsparseLtMatmulPlanDestroy()#

hipsparseStatus_t hipsparseLtMatmulPlanDestroy(const hipsparseLtMatmulPlan_t *plan)#

Destroy a matrix multiplication plan descriptor.

hipsparseLtMatmulPlanDestroy releases the resources used by an instance of the matrix multiplication plan. This function is the last call with a specific plan instance.

Parameters:

plan[in] the matrix multiplication plan descriptor.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEplan is invalid.

hipsparseLtMatmul()#

hipsparseStatus_t hipsparseLtMatmul(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, const void *alpha, const void *d_A, const void *d_B, const void *beta, const void *d_C, void *d_D, void *workspace, hipStream_t *streams, int32_t numStreams)#

Sparse matrix and dense matrix multiplication.

hipsparseLtMatmul computes the matrix multiplication of matrices A and B to produce the output matrix D, according to the following operation:

\[ D := Activation(\alpha \cdot op(A) \cdot op(B) + \beta \cdot C + bias) * scale \]

Note

This function is non-blocking and executed asynchronously with respect to the host. It can return before the actual computation has finished.

Note

This function only supports the case where D has the same shape of C.

Parameters:
  • handle[in] hipsparselt library handle.

  • plan[in] matrix multiplication plan.

  • alpha[in] scalar \(\alpha\) (float).

  • d_A[in] Pointer to the structured matrix A.

  • d_B[in] Pointer to the dense matrix B.

  • beta[in] scalar \(\beta\) (float).

  • d_C[in] Pointer to the dense matrix C.

  • d_D[out] Pointer to the dense matrix D.

  • workspace[in] Pointer to the workspace.

  • streams[in] Pointer to HIP stream array for the computation.

  • numStreams[in] Number of HIP streams in streams.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_NOT_INITIALIZEDhandle or plan is invalid.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, plan, alpha, d_A, d_B, beta, d_C , d_D , workspace, streams, or numStreams is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtMatmulSearch()#

hipsparseStatus_t hipsparseLtMatmulSearch(const hipsparseLtHandle_t *handle, hipsparseLtMatmulPlan_t *plan, const void *alpha, const void *d_A, const void *d_B, const void *beta, const void *d_C, void *d_D, void *workspace, hipStream_t *streams, int32_t numStreams)#

Sparse matrix and dense matrix multiplication.

hipsparseLtMatmulSearch evaluates all available algorithms for the matrix multiplication and automatically updates the plan by selecting the fastest one. The functionality is intended to be used for auto-tuning purposes when the same operation is repeated multiple times over different inputs.

Note

The behavior of this function is the same as hipsparseLtMatmul.

Note

d_C and d_D must be two different memory buffers, otherwise the output will be incorrect.

Note

This function is NOT asynchronous with respect to streams[0] (blocking call).

Note

The number of iterations for the evaluation can be set by using hipsparseLtMatmulAlgSetAttribute() with HIPSPARSELT_MATMUL_SEARCH_ITERATIONS.

Note

The selected algorithm id can be retrieved by using

Parameters:
  • handle[in] hipsparselt library handle.

  • plan[in] matrix multiplication plan.

  • alpha[in] scalar \(\alpha\) (float).

  • d_A[in] pointer to the structured matrix A.

  • d_B[in] pointer to the dense matrix B.

  • beta[in] scalar \(\beta\) (float).

  • d_C[in] pointer to the dense matrix C.

  • d_D[out] pointer to the dense matrix D.

  • workspace[in] pointer to the worksapce.

  • streams[in] pointer to HIP stream array for the computation.

  • numStreams[in] number of HIP streams in streams.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_NOT_INITIALIZEDhandle or plan is invalid.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, plan, alpha, d_A, d_B, beta, d_C, d_D, workspace, streams, or numStreams is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtSpMMAPrune()#

hipsparseStatus_t hipsparseLtSpMMAPrune(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulDescriptor_t *matmulDescr, const void *d_in, void *d_out, hipsparseLtPruneAlg_t pruneAlg, hipStream_t stream)#

Prune a dense matrix.

hipsparseLtSpMMAPrune prunes the dense matrix d_in according to the specified algorithm pruneAlg, which can be HIPSPARSELT_PRUNE_SPMMA_TILE or HIPSPARSELT_PRUNE_SPMMA_STRIP.

Note

The function requires no extra storage. It supports asynchronous execution with respect to stream.

Parameters:
  • handle[in] hipsparselt library handle.

  • matmulDescr[in] matrix multiplication descriptor.

  • d_in[in] pointer to the dense matrix.

  • d_out[out] pointer to the pruned matrix.

  • pruneAlg[in] pruning algorithm.

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matmulDescr, d_in, or d_out is invalid.

hipsparseLtSpMMAPruneCheck()#

hipsparseStatus_t hipsparseLtSpMMAPruneCheck(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulDescriptor_t *matmulDescr, const void *d_in, int *d_valid, hipStream_t stream)#

Check the correctness of the pruning structure for a given matrix.

hipsparseLtSpMMAPruneCheck checks the correctness of the pruning structure for a given matrix. Contents in the provided matrix must have a sparsity of 2:4.

Parameters:
  • handle[in] hipsparselt library handle.

  • matmulDescr[in] matrix multiplication descriptor.

  • d_in[in] pointer to the matrix to check.

  • d_valid[out] validation results (0 is correct, and 1 is incorrect).

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, matmulDescr, d_in, or d_valid is invalid.

hipsparseLtSpMMAPrune2()#

hipsparseStatus_t hipsparseLtSpMMAPrune2(const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *sparseMatDescr, int isSparseA, hipsparseOperation_t op, const void *d_in, void *d_out, hipsparseLtPruneAlg_t pruneAlg, hipStream_t stream)#

Prune a dense matrix.

hipsparseLtSpMMAPrune2 prunes the dense matrix d_in according to the specified algorithm pruneAlg, which can be HIPSPARSELT_PRUNE_SPMMA_TILE or HIPSPARSELT_PRUNE_SPMMA_STRIP.

Note

The function requires no extra storage. It supports asynchronous execution with respect to stream.

Parameters:
  • handle[in] hipsparselt library handle.

  • sparseMatDescr[in] structured (sparse) matrix descriptor.

  • isSparseA[in] specify if the structured (or sparse) matrix is in the first position (matA or matB). (It currently only supports matA.)

  • op[in] operation that will be applied to the structured (or sparse) matrix in the multiplication.

  • d_in[in] pointer to the dense matrix.

  • d_out[out] pointer to the pruned matrix.

  • pruneAlg[in] pruning algorithm.

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, sparseMatDescr, op, d_in, or d_out is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtSpMMAPruneCheck2()#

hipsparseStatus_t hipsparseLtSpMMAPruneCheck2(const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *sparseMatDescr, int isSparseA, hipsparseOperation_t op, const void *d_in, int *d_valid, hipStream_t stream)#

Check the correctness of the pruning structure for a given matrix.

hipsparseLtSpMMAPruneCheck2 checks the correctness of the pruning structure for a given matrix. Contents in the provided matrix must have a sparsity of 2:4.

Parameters:
  • handle[in] hipsparselt library handle.

  • sparseMatDescr[in] structured (sparse) matrix descriptor.

  • isSparseA[in] specify if the structured (or sparse) matrix is in the first position (matA or matB). (The HIP backend only supports matA.)

  • op[in] operation that will be applied to the structured (or sparse) matrix in the multiplication.

  • d_in[in] pointer to the matrix to check.

  • d_valid[out] validation results (0 is correct, and 1 is incorrect).

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, sparseMatDescr, op, d_in, or d_valid is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtSpMMACompressedSize()#

hipsparseStatus_t hipsparseLtSpMMACompressedSize(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, size_t *compressedSize, size_t *compressBufferSize)#

Provide the size of the compressed matrix.

hipsparseLtSpMMACompressedSize provides the size of the compressed matrix to be allocated before calling hipsparseLtSpMMACompress() or hipsparseLtSpMMACompress2().

Parameters:
  • handle[in] hipsparselt library handle.

  • plan[in] matrix multiplication plan descriptor.

  • compressedSize[out] size in bytes of the compressed matrix.

  • compressBufferSize[out] size in bytes for the buffer needed for the matrix compression.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, plan, compressedSize, or compressBufferSize is invalid.

hipsparseLtSpMMACompress()#

hipsparseStatus_t hipsparseLtSpMMACompress(const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, const void *d_dense, void *d_compressed, void *d_compressBuffer, hipStream_t stream)#

Compress a dense matrix to structured matrix.

hipsparseLtSpMMACompress compresses the dense matrix d_dense. The compressed matrix is intended to be used as the first/second operand A/B in the hipsparseLtMatmul() function.

Parameters:
  • handle[in] handle to the hipsparselt library context queue.

  • plan[in] matrix multiplication plan descriptor.

  • d_dense[in] pointer to the dense matrix.

  • d_compressed[out] compressed matrix and metadata.

  • d_compressBuffer[out] temporary buffer for the compression.

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, plan, d_dense, or d_compressed is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtSpMMACompressedSize2()#

hipsparseStatus_t hipsparseLtSpMMACompressedSize2(const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *sparseMatDescr, size_t *compressedSize, size_t *compressBufferSize)#

Provide the size of the compressed matrix.

hipsparseLtSpMMACompressedSize2 provides the size of the compressed matrix to be allocated before calling hipsparseLtSpMMACompress or hipsparseLtSpMMACompress2.

Parameters:
  • handle[in] hipsparselt library handle.

  • sparseMatDescr[in] structured (sparse) matrix descriptor.

  • compressedSize[out] size in bytes of the compressed matrix.

  • compressBufferSize[out] size in bytes for the buffer needed for the matrix compression.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_NOT_INITIALIZEDhandle, sparseMatDescr, compressedSize, or compressBufferSize is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.

hipsparseLtSpMMACompress2()#

hipsparseStatus_t hipsparseLtSpMMACompress2(const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *sparseMatDescr, int isSparseA, hipsparseOperation_t op, const void *d_dense, void *d_compressed, void *d_compressBuffer, hipStream_t stream)#

Compress a dense matrix to structured matrix.

hipsparseLtSpMMACompress2 compresses the dense matrix d_dense. The compressed matrix is intended to be used as the first/second operand A/B in the hipsparseLtMatmul() function.

Parameters:
  • handle[in] handle to the hipsparselt library context queue.

  • sparseMatDescr[in] structured (sparse) matrix descriptor.

  • isSparseA[in] specify whether the structured (or sparse) matrix is in the first position (matA or matB).

  • op[in] operation that will be applied to the structured (or sparse) matrix in the multiplication.

  • d_dense[in] pointer to the dense matrix.

  • d_compressed[out] compressed matrix and metadata.

  • d_compressBuffer[out] temporary buffer for the compression.

  • stream[in] HIP stream for the computation.

Return values:
  • HIPSPARSE_STATUS_SUCCESS – the operation completed successfully.

  • HIPSPARSE_STATUS_INVALID_VALUEhandle, sparseMatDescr, op, d_dense, or d_compressed is invalid.

  • HIPSPARSE_STATUS_NOT_SUPPORTED – the problem is not supported.