-
Notifications
You must be signed in to change notification settings - Fork 68
Assorted optimizations for sparse dense matrix multiplication #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7134baa
1193147
715dd78
5862843
8d7ab9c
9426aaf
4757d04
8c7039d
e9ec23c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1930,9 +1930,9 @@ function _spmul!(y::AbstractVector, A::AbstractMatrix, x::AbstractSparseVector, | |
| "Matrix A has $n columns, but vector x has a length $(length(x))")) | ||
| length(y) == m || throw(DimensionMismatch( | ||
| "Matrix A has $m rows, but vector y has a length $(length(y))")) | ||
| m == 0 && return y | ||
| m == 0 && return | ||
| β != one(β) && LinearAlgebra._rmul_or_fill!(y, β) | ||
| _iszero(α) && return y | ||
| _iszero(α) && return | ||
|
|
||
| xnzind = nonzeroinds(x) | ||
| xnzval = nonzeros(x) | ||
|
|
@@ -1946,7 +1946,6 @@ function _spmul!(y::AbstractVector, A::AbstractMatrix, x::AbstractSparseVector, | |
| end | ||
| end | ||
| end | ||
| return y | ||
| end | ||
|
|
||
| function _At_or_Ac_mul_B!(tfun::Function, | ||
|
|
@@ -1958,14 +1957,14 @@ function _At_or_Ac_mul_B!(tfun::Function, | |
| "Matrix A has $n rows, but vector x has a length $(length(x))")) | ||
| length(y) == m || throw(DimensionMismatch( | ||
| "Matrix A has $m columns, but vector y has a length $(length(y))")) | ||
| m == 0 && return y | ||
| m == 0 && return | ||
| β != one(β) && LinearAlgebra._rmul_or_fill!(y, β) | ||
| _iszero(α) && return y | ||
| _iszero(α) && return | ||
|
|
||
| xnzind = nonzeroinds(x) | ||
| xnzval = nonzeros(x) | ||
| _nnz = length(xnzind) | ||
| _nnz == 0 && return y | ||
| _nnz == 0 && return | ||
|
|
||
| Ty = promote_op(matprod, eltype(A), eltype(x)) | ||
| @inbounds for j = 1:m | ||
|
|
@@ -1975,7 +1974,7 @@ function _At_or_Ac_mul_B!(tfun::Function, | |
| end | ||
| y[j] += s * α | ||
| end | ||
| return y | ||
| return | ||
| end | ||
|
|
||
| function *(A::AdjOrTrans{<:Any,<:StridedMatrix}, x::AbstractSparseVector) | ||
|
|
@@ -2053,9 +2052,9 @@ function _spmul!(y::AbstractVector, A::AbstractSparseMatrixCSC, x::AbstractSpars | |
| "Matrix A has $n columns, but vector x has a length $(length(x))")) | ||
| length(y) == m || throw(DimensionMismatch( | ||
| "Matrix A has $m rows, but vector y has a length $(length(y))")) | ||
| m == 0 && return y | ||
| m == 0 && return | ||
| β != one(β) && LinearAlgebra._rmul_or_fill!(y, β) | ||
| _iszero(α) && return y | ||
| _iszero(α) && return | ||
|
|
||
| xnzind = nonzeroinds(x) | ||
| xnzval = nonzeros(x) | ||
|
|
@@ -2073,7 +2072,6 @@ function _spmul!(y::AbstractVector, A::AbstractSparseMatrixCSC, x::AbstractSpars | |
| end | ||
| end | ||
| end | ||
| return y | ||
| end | ||
|
|
||
| function _At_or_Ac_mul_B!(tfun::Function, | ||
|
|
@@ -2085,9 +2083,9 @@ function _At_or_Ac_mul_B!(tfun::Function, | |
| "Matrix A has $n columns, but vector x has a length $(length(x))")) | ||
| length(y) == n || throw(DimensionMismatch( | ||
| "Matrix A has $m rows, but vector y has a length $(length(y))")) | ||
| n == 0 && return y | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this type of change? In
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, I see it is tested that |
||
| n == 0 && return | ||
| β != one(β) && LinearAlgebra._rmul_or_fill!(y, β) | ||
| _iszero(α) && return y | ||
| _iszero(α) && return | ||
|
|
||
| xnzind = nonzeroinds(x) | ||
| xnzval = nonzeros(x) | ||
|
|
@@ -2102,7 +2100,6 @@ function _At_or_Ac_mul_B!(tfun::Function, | |
| 1, mx, xnzind, xnzval) | ||
| @inbounds y[j] += s * α | ||
| end | ||
| return y | ||
| end | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.