本项目是CANN提供的高性能稀疏矩阵计算的算子库,专注于优化稀疏矩阵的计算效率。
ops-sparse
🔥Latest News
- [2026/12] ops-sparse v1.0.0 is officially released, providing mainstream sparse matrix multiplication operations.
- [2026/09] The ops-sparse related open-source tasks have been released. Developers are welcome to participate and jointly improve the CANN sparse operator capabilities.
- [2026/06] Added the sparse matrix-dense matrix multiplication (SpMM) operator implementation.
- [2026/05] The ops-sparse project went online, providing sparse matrix computation APIs and an optimized sparse matrix-vector multiplication implementation.
🚀Overview
ops-sparse is an operator library in the CANN (Compute Architecture for Neural Networks) operator library that provides high-performance sparse matrix computation, focusing on optimizing the computational efficiency of sparse matrices.
🛠️Environment Preparation
Environment deployment is the prerequisite for experiencing the capabilities of this project. Complete the NPU driver and CANN package installation first to ensure the environment is normal. Obtain the CANN software packages (toolkit/ops packages) from the CANN official download center, and select the corresponding version by product series, CPU architecture, and operating system.
Note: This project supports only CANN 9.0.0 and later versions. For the mapping between the source code version and the CANN version, see the release repository.
⬇️Source Code Download
After the environment is ready, download the branch source code matching the CANN version using the following command, replacing ${tag_version} with the branch tag name.
Note: If the matching branch source code already exists in the environment, you can skip this step. For example, CANNLab provides the source code corresponding to the latest commercial-release CANN by default.
git clone -b ${tag_version} https://gitcode.com/cann/ops-sparse.git
Note: For the CANNLab cloud development environment, the source code matching the latest commercial-release CANN version is provided by default. To obtain source code of other versions, use the command above.
📖Tutorials
- Quick Start: Quickly experience the core basic capabilities of the project from scratch, covering source code compilation, operator invocation, development, debugging, and other operations.
- Operator support
- Interface list: Provides the full API information, allowing you to view the classification and functions of the aclsparse interfaces.
Operator Support
The following table summarizes the support status of the implemented computation/conversion operators on arch22 / arch35 (compiled from the source code and the product descriptions in each operator's README). General APIs such as handle/descriptor creation and destruction are not included. Entries already documented in the interface documentation are listed in the interface list (classified by general API / operator API; for some operators in this table, the detailed interface descriptions are still subject to the README.md in each operator directory, and the interface list will be continuously completed).
Legend: √ supported, × not currently supported. Columns are displayed by source architecture; the specific product support scope is subject to the README.md in each operator directory.
| Operator | Representative Interface | arch22 | arch35 |
|---|---|---|---|
| SpMV | aclsparseSpMV |
√ | √ |
| SpMVOp | aclsparseSpMVOp |
× | √ |
| SpMM | aclsparseSpMM |
√ | √ |
| SpMMOp | aclsparseSpMMOp |
× | √ |
| CubeSpMM | aclsparseCubeSpmm |
√ | × |
| CubeSpMM 1D | aclsparseCubeSpmm1dExecute |
√ | × |
| SDDMM | aclsparseSDDMM |
√ | √ |
| SpGEMM | aclsparseSpGEMM |
√ | √ |
| SpSM | aclsparseSpSM |
√ | √ |
| SpSV | aclsparseSpSV_solve |
√ | √ |
| SpVV | aclsparseSpvv |
√ | × |
| Gather | aclsparseGather |
√ | √ |
| Scatter | aclsparseScatter |
√ | √ |
| DenseToSparse | aclsparseDenseToSparseConvert |
√ | √ |
| SparseToDense | aclsparseSparseToDense |
√ | √ |
| gtsv2 | aclsparseSgtsv2 |
√ | √ |
| Cgtsv2 | aclsparseCgtsv2 |
√ | √ |
| gtsv2_nopivot | aclsparseSgtsv2Nopivot |
× | √ |
| gtsv2_strided_batch | aclsparseSgtsv2StridedBatch |
× | √ |
| gtsv_interleaved_batch | aclsparseSgtsvInterleavedBatch |
× | √ |
| gpsv_interleaved_batch | aclsparseSgpsvInterleavedBatch |
× | √ |
| CSR sorting | aclsparseXcsrsort |
× | √ |
| CSC sorting | aclsparseXcscsort |
√ | √ |
| COO sorting | aclsparseXcoosortByRow |
× | √ |
| COO→CSR | aclsparseXcoo2csr |
× | √ |
| CSR→COO | aclsparseXcsr2coo |
× | √ |
| CSR→CSC | aclsparseCsr2cscEx2 |
× | √ |
| CSR→GEBSR | aclsparseScsr2gebsr |
× | √ |
| GEBSR→GEBSC | aclsparseGebsr2gebsc |
× | √ |
| CSRGEAM2 | aclsparseScsrgeam2 |
× | √ |
| NNZ | aclsparseSnnz |
× | √ |
For finer dtype/algorithm combinations, refer to the
README.mdin each operator directory; the documented interface descriptions are indocs/en/api_list.md. For structured sparsity (aclsparseLt*), see api_list_sparseLt.md.
🔍Directory Structure
For the key directory structure of the ops-sparse repository, see Directory Structure.
Note: Standalone operator invocation samples are located in the
examples/directory (for example,examples/cube_spmm_1d/cube_spmm_1d_csr.c); thetest/directory also contains test cases (for example,test/spmv/arch22/spmv_test.cpp). For detailed invocation instructions of each operator, refer totest/<operator>/README.md.
💬Related Information
- Operator support
- Directory structure
- Interface list
- Contribution guide
- Security statement
- License
- Affiliated SIG
🤝Contact Us
The functions and documentation of this project are being continuously updated and improved. It is recommended that you follow the latest version.
- Issue feedback: Submit issues via GitCode Issues.
- Community interaction: Participate in discussions via GitCode Discussions.
- Technical column: Obtain technical articles, such as serialized tutorials and best practices, via GitCode Wiki.