/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipsparselt/checkouts/latest/projects/hipsparselt/library/include/hipsparselt.h File Reference#
hipsparselt.h provides Sparse Linear Algebra Subprograms of Prune, Compressed and Matrix Multiplication, using HIP optimized for AMD GPU hardware. More...
#include <hipsparse/hipsparse.h>#include <hipsparselt/hipsparselt-export.h>#include <hipsparselt/hipsparselt-version.h>#include <hip/hip_complex.h>#include <hip/hip_runtime_api.h>#include <hip/hip_bfloat16.h>#include <hip/hip_fp16.h>#include <hip/hip_fp8.h>#include <hip/library_types.h>Go to the source code of this file.
Data Structures | |
| struct | hipsparseLtHandle_t |
| Handle to the hipSPARSELt library context queue. More... | |
| struct | hipsparseLtMatDescriptor_t |
| Descriptor of the matrix. More... | |
| struct | hipsparseLtMatmulDescriptor_t |
| Descriptor of the matrix multiplication operation. More... | |
| struct | hipsparseLtMatmulAlgSelection_t |
| Descriptor of the matrix multiplication algorithm. More... | |
| struct | hipsparseLtMatmulPlan_t |
| Descriptor of the matrix multiplication execution plan. More... | |
Macros | |
| #define | _HIPSPARSELT_H_ |
Functions | |
| void | hipsparseLtInitialize () |
| Initialize hipSPARSELt for the current HIP device. More... | |
| hipsparseStatus_t | hipsparseLtGetVersion (const hipsparseLtHandle_t *handle, int *version) |
| Retrieve the version number of the hipSPARSELt library. More... | |
| hipsparseStatus_t | hipsparseLtGetProperty (hipLibraryPropertyType propertyType, int *value) |
| Retrieve the value of the requested property. More... | |
| hipsparseStatus_t | hipsparseLtGetGitRevision (hipsparseLtHandle_t handle, char *rev) |
| hipsparseStatus_t | hipsparseLtGetArchName (char **archName) |
| hipsparseStatus_t | hipsparseLtInit (hipsparseLtHandle_t *handle) |
| Create a hipSPARSELt handle. More... | |
| hipsparseStatus_t | hipsparseLtDestroy (const hipsparseLtHandle_t *handle) |
| Destroy a hipSPARSELt handle. More... | |
| 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. More... | |
| 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. More... | |
| hipsparseStatus_t | hipsparseLtMatDescriptorDestroy (const hipsparseLtMatDescriptor_t *matDescr) |
| Destroy a matrix descriptor. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| hipsparseStatus_t | hipsparseLtMatmulAlgSelectionInit (const hipsparseLtHandle_t *handle, hipsparseLtMatmulAlgSelection_t *algSelection, const hipsparseLtMatmulDescriptor_t *matmulDescr, hipsparseLtMatmulAlg_t alg) |
| Initializes the algorithm selection descriptor. More... | |
| hipsparseStatus_t | hipsparseLtMatmulAlgSelectionDestroy (const hipsparseLtMatmulAlgSelection_t *algSelection) |
| Destroy the algorithm selection descriptor. More... | |
| 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. More... | |
| 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. More... | |
| hipsparseStatus_t | hipsparseLtMatmulGetWorkspace (const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, size_t *workspaceSize) |
| Determines the required workspace size. More... | |
| hipsparseStatus_t | hipsparseLtMatmulPlanInit (const hipsparseLtHandle_t *handle, hipsparseLtMatmulPlan_t *plan, const hipsparseLtMatmulDescriptor_t *matmulDescr, const hipsparseLtMatmulAlgSelection_t *algSelection) |
| Initializes the matrix multiplication plan descriptor. More... | |
| hipsparseStatus_t | hipsparseLtMatmulPlanDestroy (const hipsparseLtMatmulPlan_t *plan) |
| Destroy a matrix multiplication plan descriptor. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| hipsparseStatus_t | hipsparseLtSpMMACompressedSize (const hipsparseLtHandle_t *handle, const hipsparseLtMatmulPlan_t *plan, size_t *compressedSize, size_t *compressBufferSize) |
| Provide the size of the compressed matrix. More... | |
| 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. More... | |
| hipsparseStatus_t | hipsparseLtSpMMACompressedSize2 (const hipsparseLtHandle_t *handle, const hipsparseLtMatDescriptor_t *sparseMatDescr, size_t *compressedSize, size_t *compressBufferSize) |
| Provide the size of the compressed matrix. More... | |
| 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. More... | |
Detailed Description
hipsparselt.h provides Sparse Linear Algebra Subprograms of Prune, Compressed and Matrix Multiplication, using HIP optimized for AMD GPU hardware.
Macro Definition Documentation
◆ _HIPSPARSELT_H_
| #define _HIPSPARSELT_H_ |
Enumeration Type Documentation
◆ hipsparseLtComputetype_t
Specify the compute precision modes of the matrix.
◆ hipsparseLtMatDescAttribute_t
Specify the additional attributes of a matrix descriptor.
The hipsparseLtMatDescAttribute_t enumeration is used in the hipsparseLtMatDescSetAttribute and hipsparseLtMatDescGetAttribute functions.
◆ hipsparseLtMatmulAlg_t
Specify the algorithm for matrix-matrix multiplication.
The hipsparseLtMatmulAlg_t enumeration is used in the hipsparseLtMatmulAlgSelectionInit function.
| Enumerator | |
|---|---|
| HIPSPARSELT_MATMUL_ALG_DEFAULT | |
◆ hipsparseLtMatmulAlgAttribute_t
Specify the matrix multiplication algorithm attributes.
The hipsparseLtMatmulAlgAttribute_t enumeration is used in the hipsparseLtMatmulAlgGetAttribute and hipsparseLtMatmulAlgSetAttribute functions.
◆ hipsparseLtMatmulDescAttribute_t
Specify the additional attributes of a matrix multiplication descriptor.
The hipsparseLtMatmulDescAttribute_t enumeration is used in the hipsparseLtMatmulDescSetAttribute and hipsparseLtMatmulDescGetAttribute functions.
◆ hipsparseLtPruneAlg_t
Specify the pruning algorithm to apply to the structured matrix before the compression.
The hipsparseLtPruneAlg_t enumeration is used in the hipsparseLtSpMMAPrune and hipsparseLtSpMMAPrune2 functions.
◆ hipsparseLtSparsity_t
Specify the sparsity of the structured matrix.
The enumerator specifies the sparsity ratio of the structured matrix as sparsity = nnz / total elements. The sparsity property is used in the hipsparseLtStructuredDescriptorInit function.
| Enumerator | |
|---|---|
| HIPSPARSELT_SPARSITY_50_PERCENT | 50% sparsity ratio:
|
◆ hipsparseLtSplitKMode_t
Specify the Split-K mode value.
The hipsparseLtSplitKMode_t enumeration is used by the HIPSPARSELT_MATMUL_SPLIT_K_MODE attribute in hipsparseLtMatmulAlgAttribute_t.
| Enumerator | |
|---|---|
| HIPSPARSELT_SPLIT_K_MODE_ONE_KERNEL | Use the same SP-MM kernel to do the final reduction. |
| HIPSPARSELT_SPLIT_K_MODE_TWO_KERNELS | Use another kernel to do the final reduction. |
Function Documentation
◆ 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
-
[in] handle the hipsparselt handle. [out] matDescr the pointer to the dense matrix descriptor. [in] rows number of rows. [in] cols number of columns. [in] ld leading dimension. [in] alignment memory alignment in bytes (not used by the HIP backend). [in] valueType data type of the matrix. Data type: hipDataType. [in] order memory layout: HIPSPARSE_ORDER_COLorHIPSPARSE_ORDER_ROW.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,descr,rows,cols, orldis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED rows,cols,ld,alignment,valueType, ororderis not supported.
◆ 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
-
[in] handle hipsparselt library handle
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_NOT_INITIALIZED the handleis invalid.
◆ hipsparseLtGetArchName()
| hipsparseStatus_t hipsparseLtGetArchName | ( | char ** | archName | ) |
◆ hipsparseLtGetGitRevision()
| hipsparseStatus_t hipsparseLtGetGitRevision | ( | hipsparseLtHandle_t | handle, |
| char * | rev | ||
| ) |
◆ hipsparseLtGetProperty()
| hipsparseStatus_t hipsparseLtGetProperty | ( | hipLibraryPropertyType | propertyType, |
| int * | value | ||
| ) |
Retrieve the value of the requested property.
hipsparseLtGetProperty returns the value of the requested property.
- Parameters
-
[in] propertyType hipLibraryPropertyType property type (as defined in library_types.h). [out] value value of the requested property.
- Return values
-
HIPSPARSE_STATUS_SUCCESS
◆ 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
-
[in] handle hipsparselt library handle. [out] version the version number of the library.
- Return values
-
HIPSPARSE_STATUS_SUCCESS HIPSPARSE_STATUS_INVALID_VALUE the handleis invalid.
◆ 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
-
[out] handle hipsparselt library handle.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the initialization succeeded. HIPSPARSE_STATUS_INVALID_VALUE the handleis invalid.
◆ hipsparseLtInitialize()
| void hipsparseLtInitialize | ( | ) |
Initialize hipSPARSELt for the current HIP device.
hipsparseLtInitialize Initialize hipSPARSELt for the current HIP device to avoid costly startup time at the first call on that device. This function is only supported by the HIP backend.
◆ 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
-
[in] handle the hipsparselt handle. [in] matDescr the matrix descriptor. [in] matAttribute HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE. [in,out] data the memory address containing the attribute value retrieved by this function. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,descr,data, ordataSizeis invalid.
◆ 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
-
[in] matDescr the matrix descriptor.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE descris 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
-
[in] handle the hipsparselt handle. [in,out] matDescr the matrix descriptor. [in] matAttribute HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE. [in] data pointer to the value to which the specified attribute will be set. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matmulDescr,data, ordataSizeis 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.
-
This function only supports the case where
Dhas the same shape ofC.
- Parameters
-
[in] handle hipsparselt library handle. [in] plan matrix multiplication plan. [in] alpha scalar \(\alpha\) (float). [in] d_A Pointer to the structured matrix A. [in] d_B Pointer to the dense matrix B. [in] beta scalar \(\beta\) (float). [in] d_C Pointer to the dense matrix C. [out] d_D Pointer to the dense matrix D. [in] workspace Pointer to the workspace. [in] streams Pointer to HIP stream array for the computation. [in] numStreams Number of HIP streams in streams.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_NOT_INITIALIZED handleorplanis invalid.HIPSPARSE_STATUS_INVALID_VALUE handle,plan,alpha,d_A,d_B,beta,d_C,d_D,workspace,streams, ornumStreamsis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED the problem 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
-
[in] handle the hipsparselt handle. [in] algSelection the algorithm selection descriptor. [in] attribute attributes are specified in hipsparseLtMatmulAlgAttribute_t. [in,out] data the memory address containing the attribute value retrieved by this function. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,algSelection,attribute,data, ordataSizeis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED attributeis not supported.
◆ 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
-
[in] algSelection the algorithm selection descriptor
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE algSelectionis invalid.
◆ 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
-
[in] handle the hipsparselt handle. [out] algSelection the pointer to the algorithm selection descriptor. [in] matmulDescr the matrix multiplication descriptor. [in] alg the algorithm used to perform the matrix multiplication.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matmulDescr, oralgSelectionis 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
-
[in] handle the hipsparselt handle. [in,out] algSelection the algorithm selection descriptor. [in] attribute attributes are specified in hipsparseLtMatmulAlgAttribute_t. [in] data pointer to the value to which the specified attribute will be set. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,algSelection,attribute,data, ordataSizeis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED attributeis 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
-
[in] handle the hipsparselt handle. [in] matmulDescr the matrix multiplication descriptor. [in] matmulAttribute see hipsparseLtMatmulDescAttribute_t. [in,out] data the memory address containing the attribute value retrieved by this function. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matDescr,data, ordataSizeis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED hipsparseLtMatmulDescAttribute_tis not supported.
◆ 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
-
[in] handle the hipsparselt handle. [in,out] matmulDescr the matrix multiplication descriptor. [in] opA hipsparse operation for Matrix A: HIPSPARSE_OPERATION_NON_TRANSPOSEorHIPSPARSE_OPERATION_TRANSPOSE.[in] opB hipsparse operation for Matrix B: HIPSPARSE_OPERATION_NON_TRANSPOSEorHIPSPARSE_OPERATION_TRANSPOSE.[in] matA the matrix descriptor (one and only one of matA or matB is a structured sparsity matrix). [in] matB the matrix descriptor (one and only one of matA or matB is a structured sparsity matrix). [in] matC the matrix descriptor (dense matrix). [in] matD the matrix descriptor (dense matrix). [in] computeType size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matmulDescr,opA,opB,matA,matB,matC,matD, orcomputeTypeis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED opA,opB, orcomputeTypeis 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
-
[in] handle the hipsparselt handle. [in,out] matmulDescr the matrix multiplication descriptor. [in] matmulAttribute see hipsparseLtMatmulDescAttribute_t. [in] data pointer to the value to which the specified attribute will be set. [in] dataSize size in bytes of the attribute value used for verification.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matDescr,data, ordataSizeis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED hipsparseLtMatmulDescAttribute_tis 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
-
[in] handle hipsparselt library handle. [in] plan the matrix multiplication plan descriptor. [out] workspaceSize workspace size in bytes.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,algSelection, orworkspaceSizeis invalid.
◆ 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
-
[in] plan the matrix multiplication plan descriptor.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE planis 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
-
[in] handle hipsparselt library handle. [out] plan the matrix multiplication plan descriptor. [in] matmulDescr the matrix multiplication descriptor. [in] algSelection the algorithm selection descriptor.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,plan,matmulDescr,algSelection, orworkspaceSizeis invalid. HIPSPARSELT_MAT_NUM_BATCHES from matrix A to D are inconsistent.
◆ 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.
-
d_Candd_Dmust be two different memory buffers, otherwise the output will be incorrect. -
This function is NOT asynchronous with respect to
streams[0](blocking call). -
The number of iterations for the evaluation can be set by using
hipsparseLtMatmulAlgSetAttribute()withHIPSPARSELT_MATMUL_SEARCH_ITERATIONS. - The selected algorithm id can be retrieved by using
- Parameters
-
[in] handle hipsparselt library handle. [in] plan matrix multiplication plan. [in] alpha scalar \(\alpha\) (float). [in] d_A pointer to the structured matrix A. [in] d_B pointer to the dense matrix B. [in] beta scalar \(\beta\) (float). [in] d_C pointer to the dense matrix C. [out] d_D pointer to the dense matrix D. [in] workspace pointer to the worksapce. [in] streams pointer to HIP stream array for the computation. [in] numStreams number of HIP streams in streams.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_NOT_INITIALIZED handleorplanis invalid.HIPSPARSE_STATUS_INVALID_VALUE handle,plan,alpha,d_A,d_B,beta,d_C,d_D,workspace,streams, ornumStreamsis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED the problem is not supported.
◆ 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
-
[in] handle handle to the hipsparselt library context queue. [in] plan matrix multiplication plan descriptor. [in] d_dense pointer to the dense matrix. [out] d_compressed compressed matrix and metadata. [out] d_compressBuffer temporary buffer for the compression. [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,plan,d_dense, ord_compressedis 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
-
[in] handle handle to the hipsparselt library context queue. [in] sparseMatDescr structured (sparse) matrix descriptor. [in] isSparseA specify whether the structured (or sparse) matrix is in the first position (matA or matB). [in] op operation that will be applied to the structured (or sparse) matrix in the multiplication. [in] d_dense pointer to the dense matrix. [out] d_compressed compressed matrix and metadata. [out] d_compressBuffer temporary buffer for the compression. [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,sparseMatDescr,op,d_dense, ord_compressedis 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
-
[in] handle hipsparselt library handle. [in] plan matrix multiplication plan descriptor. [out] compressedSize size in bytes of the compressed matrix. [out] compressBufferSize size in bytes for the buffer needed for the matrix compression.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,plan,compressedSize, orcompressBufferSizeis invalid.
◆ 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
-
[in] handle hipsparselt library handle. [in] sparseMatDescr structured (sparse) matrix descriptor. [out] compressedSize size in bytes of the compressed matrix. [out] compressBufferSize size in bytes for the buffer needed for the matrix compression.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_NOT_INITIALIZED handle,sparseMatDescr,compressedSize, orcompressBufferSizeis 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
-
[in] handle hipsparselt library handle. [in] matmulDescr matrix multiplication descriptor. [in] d_in pointer to the dense matrix. [out] d_out pointer to the pruned matrix. [in] pruneAlg pruning algorithm. [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matmulDescr,d_in, ord_outis 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
-
[in] handle hipsparselt library handle. [in] sparseMatDescr structured (sparse) matrix descriptor. [in] isSparseA specify if the structured (or sparse) matrix is in the first position (matA or matB). (It currently only supports matA.) [in] op operation that will be applied to the structured (or sparse) matrix in the multiplication. [in] d_in pointer to the dense matrix. [out] d_out pointer to the pruned matrix. [in] pruneAlg pruning algorithm. [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,sparseMatDescr,op,d_in, ord_outis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED the problem is not supported.
◆ 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
-
[in] handle hipsparselt library handle. [in] matmulDescr matrix multiplication descriptor. [in] d_in pointer to the matrix to check. [out] d_valid validation results (0 is correct, and 1 is incorrect). [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,matmulDescr,d_in, ord_validis invalid.
◆ 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
-
[in] handle hipsparselt library handle. [in] sparseMatDescr structured (sparse) matrix descriptor. [in] isSparseA specify if the structured (or sparse) matrix is in the first position (matA or matB). (The HIP backend only supports matA.) [in] op operation that will be applied to the structured (or sparse) matrix in the multiplication. [in] d_in pointer to the matrix to check. [out] d_valid validation results (0 is correct, and 1 is incorrect). [in] stream HIP stream for the computation.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,sparseMatDescr,op,d_in, ord_validis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED the problem 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
-
[in] handle the hipsparselt handle. [out] matDescr the pointer to the dense matrix descriptor. [in] rows number of rows. [in] cols number of columns. [in] ld leading dimension. [in] alignment memory alignment in bytes (not used by the HIP backend). [in] valueType data type of the matrix. Data type: hipDataType. [in] order memory layout: HIPSPARSE_ORDER_COLorHIPSPARSE_ORDER_ROW.[in] sparsity matrix sparsity ratio. See hipsparseLtSparsity_t.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,descr,rows,cols, orldis invalid.HIPSPARSE_STATUS_NOT_SUPPORTED rows,cols,ld,alignment,valueType, ororderis not supported.