| Files | Last commit | Last update |
|---|---|---|
SpVV (Sparse Vector - Dense Vector Dot Product) Operator
Operator Overview
aclsparseSpvv computes the dot product of a sparse vector and a dense vector, with the result being a single FP32 scalar on the Device side:
result = sum(x_values[i] * y[x_indices[i]]), i ∈ [0, nnz)
x is a sparse vector (aclsparseSpVecDescr_t, indices must be ascending and unique, 0-based, int32), y is a dense vector (aclsparseDnVecDescr_t), and result is a pointer to 1 float element on the Device side. Accumulation and output are always FP32 (computeType supports only ACL_FLOAT); the x/y element types can be ACL_FLOAT or ACL_FLOAT16 (the two must be consistent, and the kernel function dispatches by valueType).
Product support
| Product | Support Status |
|---|---|
| Atlas A2 products | Supported, arch22 / DAV_2201 |
| Atlas A3 products | Supported, arch22 / DAV_2201 |
| Ascend 950PR&950DT products | Not supported |
Interface description
aclsparseSpvv
Function prototype
aclsparseStatus_t aclsparseSpvv(aclsparseHandle_t handle, aclsparseOperation_t op,
aclsparseConstSpVecDescr_t x, aclsparseConstDnVecDescr_t y,
void* result, aclDataType computeType);
Parameter description
| Parameter | Input/Output | Parameter Type | Description |
|---|---|---|---|
| handle | Input | aclsparseHandle_t | Sparse computation handle; Host memory |
| op | Input | aclsparseOperation_t | Supports only ACL_SPARSE_OP_NON_TRANSPOSE |
| x | Input | aclsparseConstSpVecDescr_t | Sparse vector descriptor; indices must be ascending and unique; Device memory |
| y | Input | aclsparseConstDnVecDescr_t | Dense vector descriptor; Device memory |
| result | Output | void* | Pointer to 1 float element on the Device side |
| computeType | Input | aclDataType | Supports only ACL_FLOAT (accumulation/output are always FP32) |
Constraints
- op supports only
ACL_SPARSE_OP_NON_TRANSPOSE(others returnACL_SPARSE_STATUS_NOT_SUPPORTED) - computeType supports only
ACL_FLOAT; the x/y element types can beACL_FLOATorACL_FLOAT16, and the two must be consistent (inconsistency returnsACL_SPARSE_STATUS_INVALID_VALUE) - The x index type supports only
ACL_SPARSE_INDEX_32I, the base supports onlyACL_SPARSE_INDEX_BASE_ZERO, and indices must be ascending and unique (guaranteed by the caller) - Non-empty vectors must have values/indices pointers bound;
x/y/resultcannot be nullptr (an emptyhandlereturnsACL_SPARSE_STATUS_HANDLE_IS_NULLPTR, other null pointers or invalid descriptors returnACL_SPARSE_STATUS_INVALID_VALUE, and platform or internal validation exceptions returnACL_SPARSE_STATUS_INTERNAL_ERROR) - The element pointed to by result is written out asynchronously on the stream; synchronize before reading
Invocation sequence
aclsparseCreate(&handle);
aclsparseSetStream(handle, stream);
// CreateSpVec(x, size, nnz, indices, values, INDEX_32I, BASE_ZERO, FP32/FP16)
// CreateDnVec(y, size, values, same valueType as x)
aclsparseSpvv(handle, ACL_SPARSE_OP_NON_TRANSPOSE, x, y, dResult, ACL_FLOAT);
aclrtSynchronizeStream(stream); // before reading dResult
aclsparseDestroy(handle);
Directory structure
sparse/spvv/
└── arch22/ # Atlas A2 products, Atlas A3 products (DAV_2201)
├── spvv_host.cpp # Host-side API (parameter validation + kernel dispatch)
├── spvv_kernel.cpp # Kernel-side vectorized implementation
├── spvv_kernel.h # kernel_do launcher declaration
└── spvv_tiling_data.h
The test code is located in test/spvv/ (see the README in that directory).