Skip to content

Use isempty to check exit condition in default blasmul #260

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

Merged
merged 1 commit into from
Mar 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/muladd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ function default_blasmul!(α, A::AbstractMatrix, B::AbstractMatrix, β, C::Abstr

rmul!(C, β)

(iszero(mA) || iszero(nB)) && return C
iszero(nA) && return C
(isempty(C) || iszero(nA)) && return C

r = rowsupport(B,rowsupport(A,first(colsupport(A))))
jindsid = all(k -> rowsupport(B,rowsupport(A,k)) == r, colsupport(A))
Expand All @@ -203,7 +202,7 @@ function default_blasmul!(α, A::AbstractVector, B::AbstractMatrix, β, C::Abstr

rmul!(C, β)

(iszero(mA) || iszero(nB)) && return C
isempty(C) && return C

for k in colsupport(A), j in rowsupport(B)
_default_blasmul_loop!(α, A, B, β, C, k, j)
Expand All @@ -219,12 +218,15 @@ function _default_blasmul!(::IndexLinear, α, A::AbstractMatrix, B::AbstractVect
length(C) == mA || throw(DimensionMismatch("Dimensions must match"))

rmul!(C, β)
(nA == 0 || mB == 0) && return C
(isempty(C) || isempty(A)) && return C

Astride = size(A, 1) # use size, not stride, since its not pointer arithmetic

@inbounds for k in colsupport(B,1)
aoffs = (k-1)*Astride
b = B[k] * α
for i in colsupport(A,k)
C[i] += A[i,k] * b
C[i] += A[aoffs + i] * b
end
end

Expand All @@ -238,7 +240,7 @@ function _default_blasmul!(::IndexCartesian, α, A::AbstractMatrix, B::AbstractV
length(C) == mA || throw(DimensionMismatch("Dimensions must match"))

rmul!(C, β)
(nA == 0 || mB == 0) && return C
(isempty(C) || isempty(A)) && return C

@inbounds for k in colsupport(B,1)
b = B[k] * α
Expand Down
Loading