| Files | Last commit | Last update |
|---|---|---|
sparse2dense arch22 (Atlas A2 products and Atlas A3 products, DAV_2201)
The arch22 implementation of aclsparseSparseToDense (training products 910B3/910B4 within Atlas A2 products, and training product
910_93 within Atlas A3 products): op_host/ (Host validation chain CheckMeta → coordinate validation (device-side fingerprint memoization) → FillTiling)
op_kernel/(zeroing + scatter dual kernel, with a bucket-transpose / batched scatter direct-write fast path) +sparse2dense_host.cpp(public API descriptor mapping layer) +torch_extension/(aten::_to_denseNPU sparse backend).
Build
# Repository main line (libops_sparse.so, including the public entry of this operator)
bash build.sh --ops=sparse2dense # default ascend910b3
bash build.sh --ops=sparse2dense --soc=ascend910_93
# Compile and run tests (C++ UT + ST, on real NPU devices)
bash build.sh --ops=sparse2dense --run
# Torch Extension wheel (aten::_to_dense NPU registration, JIT deferred compilation)
bash build.sh --torch_extension --ops=sparse2dense
python3 -m pip install build_out/cann_ops_sparse-*.whl --force-reinstall --no-deps
Testing
- C++ UT (
test/sparse2dense/arch22/ut/): Host validation chain / tiling / overflow protection / sharding boundaries (runs on x86, with aclrt stubs and no NPU dependency). - C++ ST (
test/sparse2dense/arch22/sparse2dense_test.cpp): public API two-phase protocol + bit-wise golden (including ±0/±inf/nan bit patterns, read-only input, and storage buffer sentinels) + L2 validation chain negative cases (with precise assertions on the rejection phase and status codes). - Python end-to-end (
test/sparse2dense/python/test_sparse2dense_torch.py):aten::_to_densedispatcher registration assertions + CSR/CSC/COO × five-dtype bit-wise + int64→I32 device-side cast + out-of-order unique coordinates + COO duplicate-coordinate summation semantics (the aclsparse API layer follows an any-written-value contract for duplicate coordinates, and the torch adaptation layer pre-merges and sums them) + repeated-execution determinism + exception matrix + CPU not intercepted.
Torch Adaptation (torch_extension/)
Tensor.to_dense → aten::_to_dense (SparsePrivateUse1 / SparseCsrPrivateUse1) NPU registration;
after metadata mapping, execution goes through the aclsparseSparseToDense public API, with the entire process running on NPU without CPU fallback.
import cann_ops_sparse must come after import torch_npu (the later registration for the same Dispatcher (op, key) overrides and takes over).