| Files | Last commit | Last update |
|---|---|---|
SDDMM (Atlas A2 Products and Atlas A3 Products)
Function
SDDMM computes alpha * op(X) * op(Y) + beta * C at the existing sparse positions of CSR or BSR.
The result updates the values of C in place, and the sparse indexes and dense inputs remain read-only.
Support Scope
| Sparse Format | X/Y Type | C Value Type | Computation Type |
|---|---|---|---|
| CSR/BSR | float32 | float32 | float32 |
| CSR/BSR | complex64 | complex64 | complex64 |
| CSR/BSR | float16 | float16 or float32 | float32 |
| BSR | bfloat16 | bfloat16 or float32 | float32 |
- Indexes use int32 and support numbering starting from 0 or 1.
- BSR supports square blocks with side lengths of 2, 4, 8, 16, 32, 64, or 128, and block values support row-major and column-major orders.
- Dense matrices support row-major, column-major, padded leading dimensions, and ordinary transposition.
ACL_SPARSE_SDDMM_ALG_DEFAULTis supported, and complex scalars useaclsparseComplex.- Host and device scalars, empty matrices, and K=0 are supported.
- When beta is zero, the original values of C are ignored.
- The BSR batch count is 1 to 65535. X/Y can each be broadcast, and each batch of C can use an independent sparse structure.
Interface Conventions
Call aclsparseSDDMMBufferSize, aclsparseSDDMMPreprocess, and aclsparseSDDMM in sequence.
The workspace is at least the queried size, and its start address is aligned to 32 bytes.
The value computation is submitted to the stream specified by the caller. You should synchronize that stream before releasing inputs, outputs, or the workspace.
After modifying the sparse index addresses or content, you need to execute Preprocess again. Reusing the preprocessing state is allowed when only the values of X/Y or C are modified. After modifying the shape, layout, operation, type, or batch attributes, you need to re-preprocess. Calls on the same C descriptor should be serialized, and independent descriptors and workspaces support concurrent calls.
The logical dimensions and expanded indexes must be within the int32 range, and the doubled column range of complex numbers must also satisfy this condition. The dense row byte span must be within the uint32 range. The workspace upper limit is 64 MiB. An error is returned when the input exceeds the support scope, and the caller should ensure that the actually allocated size matches the query result.
The Torch CSR interface supports int32 and int64 indexes and rejects indexes beyond the int32 range.
torch.sparse.sampled_addmm returns an independent result, and the direct API and prepared API update values in place.
The direct API supports conjugate and negation views. When the prepared API is executed repeatedly, it uses the latest values of the original binding.
You should prepare again after modifying the storage, shape, or stride of the bound tensors.
Precision
float16 and bfloat16 inputs use float32 accumulation. The real and imaginary parts of complex64 are verified separately by float32. Formal tests use high-precision CPU reference results and compare by output type.
| Output Type | Relative Tolerance | Absolute Tolerance |
|---|---|---|
| float16 | 2^-9 | 2^-9 |
| bfloat16 | 2^-6 | 2^-6 |
| float32/complex64 component | 2^-10 | 2^-16 |
Regression tests cover different index bases, layouts, transpositions, batch broadcast, complex scalars, value updates, and high dynamic range complex inputs. When finite alpha/beta exceeds the float32 component range, the Torch interface reports a conversion overflow, and NaN/Inf keep the native conversion semantics.
Mainline Implementation Compatibility
The unified-type kernel retains contiguous/strided layouts, long sparse rows, K blocking, and FP16 tail-segment handling. Core splitting is based on the actual reduction dimension K, and FP16 supports per-non-zero-element core splitting when a single pass can cover all non-zero elements. The long-row, blocking-boundary, strided-tail-block, and saturation regression cases newly added in the mainline continue to participate in testing.