rocm.bindings.hipsparselt

Contents

rocm.bindings.hipsparselt#

2026-09-24

31 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Classes#

hipsparseLtHandle_t

Handle to the hipSPARSELt library context queue.

hipsparseLtMatDescriptor_t

Descriptor of the matrix.

hipsparseLtMatmulDescriptor_t

Descriptor of the matrix multiplication operation.

hipsparseLtMatmulAlgSelection_t

Descriptor of the matrix multiplication algorithm.

hipsparseLtMatmulPlan_t

Descriptor of the matrix multiplication execution plan

hipsparseLtSparsity_t

Specify the sparsity of the structured matrix.

hipsparseLtMatDescAttribute_t

Specify the additional attributes of a matrix descriptor.

hipsparseLtComputetype_t

Specify the compute precision modes of the matrix.

hipsparseLtMatmulDescAttribute_t

Specify the additional attributes of a matrix multiplication descriptor.

hipsparseLtMatmulAlg_t

Specify the algorithm for matrix-matrix multiplication.

hipsparseLtMatmulAlgAttribute_t

Specify the matrix multiplication algorithm attributes.

hipsparseLtPruneAlg_t

Specify the pruning algorithm to apply to the structured matrix before the compression.

hipsparseLtSplitKMode_t

Specify the Split-K mode value.

Functions#

has_symbol(→ bool)

hipsparseLtInitialize()

Initialize hipSPARSELt for the current HIP device.

hipsparseLtGetVersion(handle)

Retrieve the version number of the hipSPARSELt library.

hipsparseLtGetProperty(propertyType)

Retrieve the value of the requested property.

hipsparseLtGetGitRevision(handle, rev)

(No short description, might be part of a group.)

hipsparseLtGetArchName()

(No short description, might be part of a group.)

hipsparseLtInit(handle)

Create a hipSPARSELt handle

hipsparseLtDestroy(handle)

Destroy a hipSPARSELt handle.

hipsparseLtDenseDescriptorInit(handle, matDescr, rows, ...)

Create a descriptor for a dense matrix

hipsparseLtStructuredDescriptorInit(handle, matDescr, ...)

Create a descriptor for a structured matrix.

hipsparseLtMatDescriptorDestroy(matDescr)

Destroy a matrix descriptor.

hipsparseLtMatDescSetAttribute(handle, matDescr, ...)

Specify the matrix attribute of a matrix descriptor.

hipsparseLtMatDescGetAttribute(handle, matDescr, ...)

Get the matrix type of a matrix descriptor.

hipsparseLtMatmulDescriptorInit(handle, matmulDescr, ...)

Initializes the matrix multiplication descriptor.

hipsparseLtMatmulDescSetAttribute(handle, matmulDescr, ...)

Specify the matrix attribute of a matrix descriptor.

hipsparseLtMatmulDescGetAttribute(handle, matmulDescr, ...)

Get the matrix type of a matrix descriptor.

hipsparseLtMatmulAlgSelectionInit(handle, ...)

Initializes the algorithm selection descriptor.

hipsparseLtMatmulAlgSelectionDestroy(algSelection)

Destroy the algorithm selection descriptor.

hipsparseLtMatmulAlgSetAttribute(handle, algSelection, ...)

Specify the algorithm attribute of a algorithm selection descriptor.

hipsparseLtMatmulAlgGetAttribute(handle, algSelection, ...)

Get the specific algorithm attribute from the algorithm selection descriptor.

hipsparseLtMatmulGetWorkspace(handle, plan, workspaceSize)

Determines the required workspace size.

hipsparseLtMatmulPlanInit(handle, plan, matmulDescr, ...)

Initializes the matrix multiplication plan descriptor.

hipsparseLtMatmulPlanDestroy(plan)

Destroy a matrix multiplication plan descriptor.

hipsparseLtMatmul(handle, plan, alpha, d_A, d_B, beta, ...)

Sparse matrix and dense matrix multiplication.

hipsparseLtMatmulSearch(handle, plan, alpha, d_A, d_B, ...)

Sparse matrix and dense matrix multiplication

hipsparseLtSpMMAPrune(handle, matmulDescr, d_in, ...)

Prune a dense matrix.

hipsparseLtSpMMAPruneCheck(handle, matmulDescr, d_in, ...)

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

hipsparseLtSpMMAPrune2(handle, sparseMatDescr, ...)

Prune a dense matrix.

hipsparseLtSpMMAPruneCheck2(handle, sparseMatDescr, ...)

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

hipsparseLtSpMMACompressedSize(handle, plan, ...)

Provide the size of the compressed matrix.

hipsparseLtSpMMACompress(handle, plan, d_dense, ...)

Compress a dense matrix to structured matrix.

hipsparseLtSpMMACompressedSize2(handle, ...)

Provide the size of the compressed matrix.

hipsparseLtSpMMACompress2(handle, sparseMatDescr, ...)

Compress a dense matrix to structured matrix.

Module Contents#

rocm.bindings.hipsparselt.has_symbol(name: str | bytes | bytearray) → bool#
class rocm.bindings.hipsparselt.hipsparseLtHandle_t(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Handle to the hipSPARSELt library context queue.

The hipSPARSELt handle is a structure holding the hipSPARSELt library context. It must be initialized using hipsparseLtInit and the returned handle must be passed to all subsequent library function calls. It should be destroyed at the end using hipsparseLtDestroy .

data: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hipsparselt.hipsparseLtMatDescriptor_t(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Descriptor of the matrix.

The hipSPARSELt matrix descriptor is a structure holding all properties of a matrix. It must be initialized using hipsparseLtDenseDescriptorInit and the returned descriptor must be passed to all subsequent library calls that involve the matrix. It should be destroyed at the end using hipsparseLtMatDescriptorDestroy .

data: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hipsparselt.hipsparseLtMatmulDescriptor_t(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Descriptor of the matrix multiplication operation.

The hipSPARSELt matrix multiplication descriptor is a structure holding the description of the matrix multiplication operation. It is initialized with the hipsparseLtMatmulDescriptorInit function.

data: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hipsparselt.hipsparseLtMatmulAlgSelection_t(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Descriptor of the matrix multiplication algorithm.

It is initialized with the hipsparseLtMatmulAlgSelectionInit function.

data: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hipsparselt.hipsparseLtMatmulPlan_t(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Descriptor of the matrix multiplication execution plan

The hipSPARSELt matrix multiplication execution plan descriptor is a structure holding all the information necessary to execute the hipsparseLtMatmul operation. It is initialized and destroyed using the hipsparseLtMatmulPlanInit and hipsparseLtMatmulPlanDestroy functions, respectively.

data: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hipsparselt.hipsparseLtSparsity_t#

Bases: enum.IntEnum

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.

HIPSPARSELT_SPARSITY_50_PERCENT: int#
class rocm.bindings.hipsparselt.hipsparseLtMatDescAttribute_t#

Bases: enum.IntEnum

Specify the additional attributes of a matrix descriptor.

The hipsparseLtMatDescAttribute_t enumeration is used in the hipsparseLtMatDescSetAttribute and hipsparseLtMatDescGetAttribute functions.

HIPSPARSELT_MAT_NUM_BATCHES: int#
HIPSPARSELT_MAT_BATCH_STRIDE: int#
class rocm.bindings.hipsparselt.hipsparseLtComputetype_t#

Bases: enum.IntEnum

Specify the compute precision modes of the matrix.

HIPSPARSELT_COMPUTE_16F: int#
HIPSPARSELT_COMPUTE_32I: int#
HIPSPARSELT_COMPUTE_32F: int#
HIPSPARSELT_COMPUTE_TF32: int#
HIPSPARSELT_COMPUTE_TF32_FAST: int#
class rocm.bindings.hipsparselt.hipsparseLtMatmulDescAttribute_t#

Bases: enum.IntEnum

Specify the additional attributes of a matrix multiplication descriptor.

The hipsparseLtMatmulDescAttribute_t enumeration is used in the hipsparseLtMatmulDescSetAttribute and hipsparseLtMatmulDescGetAttribute functions.

HIPSPARSELT_MATMUL_ACTIVATION_RELU: int#
HIPSPARSELT_MATMUL_ACTIVATION_RELU_UPPERBOUND: int#
HIPSPARSELT_MATMUL_ACTIVATION_RELU_THRESHOLD: int#
HIPSPARSELT_MATMUL_ACTIVATION_GELU: int#
HIPSPARSELT_MATMUL_ACTIVATION_GELU_SCALING: int#
HIPSPARSELT_MATMUL_ALPHA_VECTOR_SCALING: int#
HIPSPARSELT_MATMUL_BETA_VECTOR_SCALING: int#
HIPSPARSELT_MATMUL_BIAS_STRIDE: int#
HIPSPARSELT_MATMUL_BIAS_POINTER: int#
HIPSPARSELT_MATMUL_ACTIVATION_ABS: int#
HIPSPARSELT_MATMUL_ACTIVATION_LEAKYRELU: int#
HIPSPARSELT_MATMUL_ACTIVATION_LEAKYRELU_ALPHA: int#
HIPSPARSELT_MATMUL_ACTIVATION_SIGMOID: int#
HIPSPARSELT_MATMUL_ACTIVATION_TANH: int#
HIPSPARSELT_MATMUL_ACTIVATION_TANH_ALPHA: int#
HIPSPARSELT_MATMUL_ACTIVATION_TANH_BETA: int#
HIPSPARSELT_MATMUL_BIAS_TYPE: int#
HIPSPARSELT_MATMUL_SPARSE_MAT_POINTER: int#
HIPSPARSELT_MATMUL_GATE_RESIDUAL_MAT_POINTER: int#
HIPSPARSELT_MATMUL_GATE_RESIDUAL_DESC: int#
class rocm.bindings.hipsparselt.hipsparseLtMatmulAlg_t#

Bases: enum.IntEnum

Specify the algorithm for matrix-matrix multiplication.

The hipsparseLtMatmulAlg_t enumeration is used in the hipsparseLtMatmulAlgSelectionInit function.

HIPSPARSELT_MATMUL_ALG_DEFAULT: int#
class rocm.bindings.hipsparselt.hipsparseLtMatmulAlgAttribute_t#

Bases: enum.IntEnum

Specify the matrix multiplication algorithm attributes.

The hipsparseLtMatmulAlgAttribute_t enumeration is used in the hipsparseLtMatmulAlgGetAttribute and hipsparseLtMatmulAlgSetAttribute functions.

HIPSPARSELT_MATMUL_ALG_CONFIG_ID: int#
HIPSPARSELT_MATMUL_ALG_CONFIG_MAX_ID: int#
HIPSPARSELT_MATMUL_SEARCH_ITERATIONS: int#
HIPSPARSELT_MATMUL_SPLIT_K: int#
HIPSPARSELT_MATMUL_SPLIT_K_MODE: int#
HIPSPARSELT_MATMUL_SPLIT_K_BUFFERS: int#
class rocm.bindings.hipsparselt.hipsparseLtPruneAlg_t#

Bases: enum.IntEnum

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.

HIPSPARSELT_PRUNE_SPMMA_TILE: int#
HIPSPARSELT_PRUNE_SPMMA_STRIP: int#
class rocm.bindings.hipsparselt.hipsparseLtSplitKMode_t#

Bases: enum.IntEnum

Specify the Split-K mode value.

The hipsparseLtSplitKMode_t enumeration is used by the HIPSPARSELT_MATMUL_SPLIT_K_MODE attribute in hipsparseLtMatmulAlgAttribute_t .

HIPSPARSELT_SPLIT_K_MODE_ONE_KERNEL: int#
HIPSPARSELT_SPLIT_K_MODE_TWO_KERNELS: int#
rocm.bindings.hipsparselt.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.

Returns:

A tuple of size 1 that contains (in that order):

C signature

void hipsparseLtInitialize()
rocm.bindings.hipsparselt.hipsparseLtGetVersion(handle)#

Retrieve the version number of the hipSPARSELt library.

hipsparseLtGetVersion returns the version number of the hipSPARSELt library.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtGetVersion(const hipsparseLtHandle_t * handle, int * version)
rocm.bindings.hipsparselt.hipsparseLtGetProperty(propertyType)#

Retrieve the value of the requested property.

hipsparseLtGetProperty returns the value of the requested property.

Args:
propertyType (hipLibraryPropertyType) – IN:

hipLibraryPropertyType property type (as defined in library_types.h).

Returns:

A tuple of size 2 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtGetProperty(hipLibraryPropertyType propertyType, int * value)
rocm.bindings.hipsparselt.hipsparseLtGetGitRevision(handle, rev)#

(No short description, might be part of a group.)

Args:
handle (hipsparseLtHandle_t):

(undocumented)

rev (Pointer/object):

(undocumented)

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtGetGitRevision(hipsparseLtHandle_t handle, char * rev)
rocm.bindings.hipsparselt.hipsparseLtGetArchName()#

(No short description, might be part of a group.)

Returns:

A tuple of size 2 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtGetArchName(char ** archName)
rocm.bindings.hipsparselt.hipsparseLtInit(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().

Args:
handle (hipsparseLtHandle_t/object) – OUT:

hipsparselt library handle.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtInit(hipsparseLtHandle_t * handle)
rocm.bindings.hipsparselt.hipsparseLtDestroy(handle)#

Destroy a hipSPARSELt handle.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtDestroy(const hipsparseLtHandle_t * handle)
rocm.bindings.hipsparselt.hipsparseLtDenseDescriptorInit(handle, matDescr, rows, cols, ld, alignment, valueType, order)#

Create a descriptor for a dense matrix

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matDescr (hipsparseLtMatDescriptor_t/object) – OUT:

the pointer to the dense matrix descriptor.

rows (int) – IN:

number of rows.

cols (int) – IN:

number of columns.

ld (int) – IN:

leading dimension.

alignment (int) – IN:

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

valueType (hipDataType) – IN:

data type of the matrix. Data type: hipDataType.

order (hipsparseOrder_t) – IN:

memory layout: HIPSPARSE_ORDER_COL or HIPSPARSE_ORDER_ROW.

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtStructuredDescriptorInit(handle, matDescr, rows, cols, ld, alignment, valueType, order, sparsity)#

Create a descriptor for a structured matrix.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matDescr (hipsparseLtMatDescriptor_t/object) – OUT:

the pointer to the dense matrix descriptor.

rows (int) – IN:

number of rows.

cols (int) – IN:

number of columns.

ld (int) – IN:

leading dimension.

alignment (int) – IN:

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

valueType (hipDataType) – IN:

data type of the matrix. Data type: hipDataType.

order (hipsparseOrder_t) – IN:

memory layout: HIPSPARSE_ORDER_COL or HIPSPARSE_ORDER_ROW.

sparsity (hipsparseLtSparsity_t) – IN:

matrix sparsity ratio. See hipsparseLtSparsity_t .

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtMatDescriptorDestroy(matDescr)#

Destroy a matrix descriptor.

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

Args:
matDescr (hipsparseLtMatDescriptor_t/object) – IN:

the matrix descriptor.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatDescriptorDestroy(const hipsparseLtMatDescriptor_t * matDescr)
rocm.bindings.hipsparselt.hipsparseLtMatDescSetAttribute(handle, matDescr, matAttribute, data, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matDescr (hipsparseLtMatDescriptor_t/object) – INOUT:

the matrix descriptor.

matAttribute (hipsparseLtMatDescAttribute_t) – IN:

HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE .

data (Pointer/object) – IN:

pointer to the value to which the specified attribute will be set.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatDescSetAttribute(const hipsparseLtHandle_t * handle, hipsparseLtMatDescriptor_t * matDescr, hipsparseLtMatDescAttribute_t matAttribute, const void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatDescGetAttribute(handle, matDescr, matAttribute, data, dataSize)#

Get the matrix type of a matrix descriptor.

hipsparseLtMatDescGetAttribute returns the matrix attribute of a matrix descriptor.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matDescr (hipsparseLtMatDescriptor_t/object) – IN:

the matrix descriptor.

matAttribute (hipsparseLtMatDescAttribute_t) – IN:

HIPSPARSELT_MAT_NUM_BATCHES or HIPSPARSELT_MAT_BATCH_STRIDE .

data (Pointer/object) – INOUT:

the memory address containing the attribute value retrieved by this function.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatDescGetAttribute(const hipsparseLtHandle_t * handle, const hipsparseLtMatDescriptor_t * matDescr, hipsparseLtMatDescAttribute_t matAttribute, void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulDescriptorInit(handle, matmulDescr, opA, opB, matA, matB, matC, matD, computeType)#

Initializes the matrix multiplication descriptor.

hipsparseLtMatmulDescriptorInit creates a matrix multiplication descriptor.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – INOUT:

the matrix multiplication descriptor.

opA (hipsparseOperation_t) – IN:

hipsparse operation for Matrix A: HIPSPARSE_OPERATION_NON_TRANSPOSE or HIPSPARSE_OPERATION_TRANSPOSE.

opB (hipsparseOperation_t) – IN:

hipsparse operation for Matrix B: HIPSPARSE_OPERATION_NON_TRANSPOSE or HIPSPARSE_OPERATION_TRANSPOSE.

matA (hipsparseLtMatDescriptor_t/object) – IN:

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

matB (hipsparseLtMatDescriptor_t/object) – IN:

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

matC (hipsparseLtMatDescriptor_t/object) – IN:

the matrix descriptor (dense matrix).

matD (hipsparseLtMatDescriptor_t/object) – IN:

the matrix descriptor (dense matrix).

computeType (hipsparseLtComputetype_t) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtMatmulDescSetAttribute(handle, matmulDescr, matmulAttribute, data, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – INOUT:

the matrix multiplication descriptor.

matmulAttribute (hipsparseLtMatmulDescAttribute_t) – IN:

see hipsparseLtMatmulDescAttribute_t .

data (Pointer/object) – IN:

pointer to the value to which the specified attribute will be set.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulDescSetAttribute(const hipsparseLtHandle_t * handle, hipsparseLtMatmulDescriptor_t * matmulDescr, hipsparseLtMatmulDescAttribute_t matmulAttribute, const void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulDescGetAttribute(handle, matmulDescr, matmulAttribute, data, dataSize)#

Get the matrix type of a matrix descriptor.

hipsparseLtMatmulDescGetAttribute returns the matrix attribute of a matrix descriptor.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – IN:

the matrix multiplication descriptor.

matmulAttribute (hipsparseLtMatmulDescAttribute_t) – IN:

see hipsparseLtMatmulDescAttribute_t .

data (Pointer/object) – INOUT:

the memory address containing the attribute value retrieved by this function.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulDescGetAttribute(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulDescriptor_t * matmulDescr, hipsparseLtMatmulDescAttribute_t matmulAttribute, void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulAlgSelectionInit(handle, algSelection, matmulDescr, alg)#

Initializes the algorithm selection descriptor.

hipsparseLtMatmulAlgSelectionInit creates a algorithm selection descriptor.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

algSelection (hipsparseLtMatmulAlgSelection_t/object) – OUT:

the pointer to the algorithm selection descriptor.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – IN:

the matrix multiplication descriptor.

alg (hipsparseLtMatmulAlg_t) – IN:

the algorithm used to perform the matrix multiplication.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulAlgSelectionInit(const hipsparseLtHandle_t * handle, hipsparseLtMatmulAlgSelection_t * algSelection, const hipsparseLtMatmulDescriptor_t * matmulDescr, hipsparseLtMatmulAlg_t alg)
rocm.bindings.hipsparselt.hipsparseLtMatmulAlgSelectionDestroy(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.

Args:
algSelection (hipsparseLtMatmulAlgSelection_t/object) – IN:

the algorithm selection descriptor

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulAlgSelectionDestroy(const hipsparseLtMatmulAlgSelection_t * algSelection)
rocm.bindings.hipsparselt.hipsparseLtMatmulAlgSetAttribute(handle, algSelection, attribute, data, dataSize)#

Specify the algorithm attribute of a algorithm selection descriptor.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

algSelection (hipsparseLtMatmulAlgSelection_t/object) – INOUT:

the algorithm selection descriptor.

attribute (hipsparseLtMatmulAlgAttribute_t) – IN:

attributes are specified in hipsparseLtMatmulAlgAttribute_t .

data (Pointer/object) – IN:

pointer to the value to which the specified attribute will be set.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulAlgSetAttribute(const hipsparseLtHandle_t * handle, hipsparseLtMatmulAlgSelection_t * algSelection, hipsparseLtMatmulAlgAttribute_t attribute, const void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulAlgGetAttribute(handle, algSelection, attribute, data, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

the hipsparselt handle.

algSelection (hipsparseLtMatmulAlgSelection_t/object) – IN:

the algorithm selection descriptor.

attribute (hipsparseLtMatmulAlgAttribute_t) – IN:

attributes are specified in hipsparseLtMatmulAlgAttribute_t .

data (Pointer/object) – INOUT:

the memory address containing the attribute value retrieved by this function.

dataSize (int) – IN:

size in bytes of the attribute value used for verification.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulAlgGetAttribute(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulAlgSelection_t * algSelection, hipsparseLtMatmulAlgAttribute_t attribute, void * data, size_t dataSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulGetWorkspace(handle, plan, workspaceSize)#

Determines the required workspace size.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

plan (hipsparseLtMatmulPlan_t/object) – IN:

the matrix multiplication plan descriptor.

workspaceSize (PointerToUInt64/object) – OUT:

workspace size in bytes.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulGetWorkspace(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulPlan_t * plan, size_t * workspaceSize)
rocm.bindings.hipsparselt.hipsparseLtMatmulPlanInit(handle, plan, matmulDescr, algSelection)#

Initializes the matrix multiplication plan descriptor.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

plan (hipsparseLtMatmulPlan_t/object) – OUT:

the matrix multiplication plan descriptor.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – IN:

the matrix multiplication descriptor.

algSelection (hipsparseLtMatmulAlgSelection_t/object) – IN:

the algorithm selection descriptor.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulPlanInit(const hipsparseLtHandle_t * handle, hipsparseLtMatmulPlan_t * plan, const hipsparseLtMatmulDescriptor_t * matmulDescr, const hipsparseLtMatmulAlgSelection_t * algSelection)
rocm.bindings.hipsparselt.hipsparseLtMatmulPlanDestroy(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.

Args:
plan (hipsparseLtMatmulPlan_t/object) – IN:

the matrix multiplication plan descriptor.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtMatmulPlanDestroy(const hipsparseLtMatmulPlan_t * plan)
rocm.bindings.hipsparselt.hipsparseLtMatmul(handle, plan, alpha, d_A, d_B, beta, d_C, d_D, workspace, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

plan (hipsparseLtMatmulPlan_t/object) – IN:

matrix multiplication plan.

alpha (Pointer/object) – IN:

scalar \(\alpha\) (float).

d_A (Pointer/object) – IN:

Pointer to the structured matrix A.

d_B (Pointer/object) – IN:

Pointer to the dense matrix B.

beta (Pointer/object) – IN:

scalar \(\beta\) (float).

d_C (Pointer/object) – IN:

Pointer to the dense matrix C.

d_D (Pointer/object) – OUT:

Pointer to the dense matrix D.

workspace (Pointer/object) – IN:

Pointer to the workspace.

numStreams (int) – IN:

Number of HIP streams in streams.

Returns:

A tuple of size 2 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtMatmulSearch(handle, plan, alpha, d_A, d_B, beta, d_C, d_D, workspace, 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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

plan (hipsparseLtMatmulPlan_t/object) – IN:

matrix multiplication plan.

alpha (Pointer/object) – IN:

scalar \(\alpha\) (float).

d_A (Pointer/object) – IN:

pointer to the structured matrix A.

d_B (Pointer/object) – IN:

pointer to the dense matrix B.

beta (Pointer/object) – IN:

scalar \(\beta\) (float).

d_C (Pointer/object) – IN:

pointer to the dense matrix C.

d_D (Pointer/object) – OUT:

pointer to the dense matrix D.

workspace (Pointer/object) – IN:

pointer to the worksapce.

numStreams (int) – IN:

number of HIP streams in streams.

Returns:

A tuple of size 2 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtSpMMAPrune(handle, matmulDescr, d_in, d_out, pruneAlg, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – IN:

matrix multiplication descriptor.

d_in (Pointer/object) – IN:

pointer to the dense matrix.

d_out (Pointer/object) – OUT:

pointer to the pruned matrix.

pruneAlg (hipsparseLtPruneAlg_t) – IN:

pruning algorithm.

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtSpMMAPrune(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulDescriptor_t * matmulDescr, const void * d_in, void * d_out, hipsparseLtPruneAlg_t pruneAlg, hipStream_t stream)
rocm.bindings.hipsparselt.hipsparseLtSpMMAPruneCheck(handle, matmulDescr, d_in, d_valid, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

matmulDescr (hipsparseLtMatmulDescriptor_t/object) – IN:

matrix multiplication descriptor.

d_in (Pointer/object) – IN:

pointer to the matrix to check.

d_valid (PointerToInt/object) – OUT:

validation results (0 is correct, and 1 is incorrect).

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtSpMMAPruneCheck(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulDescriptor_t * matmulDescr, const void * d_in, int * d_valid, hipStream_t stream)
rocm.bindings.hipsparselt.hipsparseLtSpMMAPrune2(handle, sparseMatDescr, isSparseA, op, d_in, d_out, pruneAlg, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

sparseMatDescr (hipsparseLtMatDescriptor_t/object) – IN:

structured (sparse) matrix descriptor.

isSparseA (int) – IN:

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

op (hipsparseOperation_t) – IN:

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

d_in (Pointer/object) – IN:

pointer to the dense matrix.

d_out (Pointer/object) – OUT:

pointer to the pruned matrix.

pruneAlg (hipsparseLtPruneAlg_t) – IN:

pruning algorithm.

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtSpMMAPruneCheck2(handle, sparseMatDescr, isSparseA, op, d_in, d_valid, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

sparseMatDescr (hipsparseLtMatDescriptor_t/object) – IN:

structured (sparse) matrix descriptor.

isSparseA (int) – IN:

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

op (hipsparseOperation_t) – IN:

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

d_in (Pointer/object) – IN:

pointer to the matrix to check.

d_valid (PointerToInt/object) – OUT:

validation results (0 is correct, and 1 is incorrect).

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)
rocm.bindings.hipsparselt.hipsparseLtSpMMACompressedSize(handle, plan, compressedSize, compressBufferSize)#

Provide the size of the compressed matrix.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

plan (hipsparseLtMatmulPlan_t/object) – IN:

matrix multiplication plan descriptor.

compressedSize (PointerToUInt64/object) – OUT:

size in bytes of the compressed matrix.

compressBufferSize (PointerToUInt64/object) – OUT:

size in bytes for the buffer needed for the matrix compression.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtSpMMACompressedSize(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulPlan_t * plan, size_t * compressedSize, size_t * compressBufferSize)
rocm.bindings.hipsparselt.hipsparseLtSpMMACompress(handle, plan, d_dense, d_compressed, d_compressBuffer, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

handle to the hipsparselt library context queue.

plan (hipsparseLtMatmulPlan_t/object) – IN:

matrix multiplication plan descriptor.

d_dense (Pointer/object) – IN:

pointer to the dense matrix.

d_compressed (Pointer/object) – OUT:

compressed matrix and metadata.

d_compressBuffer (Pointer/object) – OUT:

temporary buffer for the compression.

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtSpMMACompress(const hipsparseLtHandle_t * handle, const hipsparseLtMatmulPlan_t * plan, const void * d_dense, void * d_compressed, void * d_compressBuffer, hipStream_t stream)
rocm.bindings.hipsparselt.hipsparseLtSpMMACompressedSize2(handle, sparseMatDescr, compressedSize, compressBufferSize)#

Provide the size of the compressed matrix.

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

Args:
handle (hipsparseLtHandle_t/object) – IN:

hipsparselt library handle.

sparseMatDescr (hipsparseLtMatDescriptor_t/object) – IN:

structured (sparse) matrix descriptor.

compressedSize (PointerToUInt64/object) – OUT:

size in bytes of the compressed matrix.

compressBufferSize (PointerToUInt64/object) – OUT:

size in bytes for the buffer needed for the matrix compression.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hipsparseStatus_t hipsparseLtSpMMACompressedSize2(const hipsparseLtHandle_t * handle, const hipsparseLtMatDescriptor_t * sparseMatDescr, size_t * compressedSize, size_t * compressBufferSize)
rocm.bindings.hipsparselt.hipsparseLtSpMMACompress2(handle, sparseMatDescr, isSparseA, op, d_dense, d_compressed, d_compressBuffer, 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.

Args:
handle (hipsparseLtHandle_t/object) – IN:

handle to the hipsparselt library context queue.

sparseMatDescr (hipsparseLtMatDescriptor_t/object) – IN:

structured (sparse) matrix descriptor.

isSparseA (int) – IN:

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

op (hipsparseOperation_t) – IN:

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

d_dense (Pointer/object) – IN:

pointer to the dense matrix.

d_compressed (Pointer/object) – OUT:

compressed matrix and metadata.

d_compressBuffer (Pointer/object) – OUT:

temporary buffer for the compression.

stream (Pointer/object) – IN:

HIP stream for the computation.

Returns:

A tuple of size 1 that contains (in that order):

C signature

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)