Project Directory
Some directories or files listed in this chapter are optional; refer to the actual deliverables. Also note:
- Operator source directory: organized by operator name under
sparse/(such assparse/spmv/andsparse/spmm/); the implementations for each platform go into the${arch_dir}/subdirectory, and--socdetermines which implementation is built.- Multiple architectures coexist: Atlas A2 products and Atlas A3 products (
dav-2201) →arch22; Ascend 950PR&950DT products (dav-3510) →arch35; 310P (dav-2002) →arch20. Currently bothspmvandspmmcontainarch22/andarch35/implementations; the specific support capabilities are subject to the corresponding operator descriptions.- sparseLt directory:
sparseLt/is the advanced sparse matrix operation library (analogous to blasLt in ops-blas), already containing library management, descriptors, algorithm selection, execution plans, and the matmul computation interface.- Test directory: organized by operator name under
test/(such astest/spmv/andtest/spmm/); each operator directory contains the corresponding test source code and documentation. Seetest/<operator>/README.mdfor the test entry and reproduction steps; the operator's semantics and interface descriptions are subject tosparse/<operator>/README.md.- Test project: cases under
test/participate in the build only whenBUILD_TESTis enabled andOP_LIST(semicolon-separated operator test subdirectory names) is set during project configuration. See the root-directory CMakeLists.txt and the QuickStart for details.- To add operators or documentation, feel free to refer to the Contribution Guide.
The full directory hierarchy of the project is described as follows:
├── sparse # Sparse operator source directory
│ ├── CMakeLists.txt # sparse source file collection and build rules
│ ├── common # Common code such as initialization and context management
│ │ ├── aclsparse_handle_internal.h # Internal handle definitions
│ │ ├── aclsparse_descr_internal.h # Internal descriptor definitions
│ │ ├── aclsparse_host_utils.h # Host-side utility functions and macros (CHECK_RET, CHECK_ACL, etc.)
│ │ ├── aclsparse_auxiliary.cpp # Auxiliary function implementation
│ │ ├── aclsparse_logger_manager.h # Logger manager header file
│ │ └── aclsparse_logger_manager.cpp # Logger manager implementation
│ └── ${operator} # Operator directory (such as spmv, spmm, csrgeam2)
│ ├── README.md # Operator description document and invocation samples
│ └── ${arch_dir}/ # Architecture-specific source code (such as arch22 and arch35); whether it is built depends on the SOC configuration
│ ├── ${operator}_host.cpp # Host side: parameter checks, task dispatch, etc.
│ ├── ${operator}_kernel.cpp # Device side: Ascend C kernel function entry (or multiple kernels/*.cpp files)
│ ├── ${operator}_csr_mat.h # Optional, CSR matrix data structure header file
│ ├── ${operator}_csr_mat.cpp # Optional, CSR matrix processing implementation
│ └── ${operator}.h # Operator internal header file
├── sparseLt # Advanced sparse matrix operation library (library management, descriptors, algorithm selection, and execution plan interfaces implemented)
│ ├── CMakeLists.txt # sparseLt source file collection and build rules
│ ├── common # Handles, error handling, and cross-operator common capabilities (host-side C++)
│ ├── ${operator} # Operator directory (such as prune), containing implementation files, internal headers, and README
│ └── shared # host/kernel shared headers and platform query helpers
├── include # Public header files
│ ├── cann_ops_sparse.h # aclsparse API declarations (pure C, including common type definitions)
│ └── cann_ops_sparseLt.h # aclsparseLt API declarations (including library management and descriptor interfaces; includes cann_ops_sparse.h)
├── docs # Project documentation
│ ├── QUICKSTART.md # Quick start
│ └── zh
│ ├── api_list.md # Interface list
│ ├── api_list_sparseLt.md # aclsparseLt interface list
│ ├── develop # Development guide
│ │ ├── compile_and_run_example.md # Build and run example
│ │ └── readme_develop_guide.md # Operator README writing template
│ ├── figures # Document figures
│ └── install
│ ├── quick_install.md # Environment deployment
│ └── dir_structure.md # Directory structure
├── cmake # Build function library (test.cmake for test target registration, package.cmake for packaging, makeself.cmake for self-extracting run packages, version.cmake for version info, and third_party dependencies)
├── torch_extension # PyTorch integration framework (torch.ops registration of operators and Python bindings; see torch_extension/README.md for details)
│ ├── cann_ops_sparse # Python package source and per-operator extensions (csrc binding sources are compiled separately by PyTorch JIT and are not included in libops_sparse)
│ ├── setup.py # pip installation entry (depends on torch>=2.6.0 and torch_npu)
│ └── MANIFEST.in / requirements.txt # Packaging manifest and Python dependencies
├── torch_npu # PyTorch/torch_npu SpMV bridge (optional target BUILD_TORCH_ADAPTER, OFF by default)
├── examples # Standalone operator invocation sample code (such as cube_spmm_1d/cube_spmm_1d_csr.c)
├── scripts # Helper scripts (packaging installation notes, version info generation, etc.)
│ ├── package
│ └── util
├── tests # Host-side script self-tests (different from the operator-level tests in test/)
├── agent # Agent workflow configuration (skill definitions and initialization scripts)
├── test # Operator-level tests (included in the build when BUILD_TEST=ON and OP_LIST is configured)
│ ├── CMakeLists.txt # Batch add_subdirectory by OP_LIST
│ └── ${operator} # Operator directory (such as spmv and spmm)
│ ├── CMakeLists.txt
│ ├── README.md # Optional, operator description document and invocation samples
│ └── ${arch_dir}/ # Architecture-specific tests, corresponding to the sparse-side arch directories
│ └── ${operator}_test.cpp # Executable test source file
├── CMakeLists.txt # Project entry: ops_sparse / ops_sparseLt libraries, installation rules, optional tests, and packaging
├── CONTRIBUTING.md # Contribution guide
├── LICENSE # Open-source license
├── README.md # Project overview
├── SECURITY.md # Security statement
├── build.sh # Build script
├── install_deps.sh # Dependency installation script
└── ...