Skip to content

Relax stride(A,2) requirements in BLAS.gemv! #42012

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ for (fname, elty) in ((:dgemv_,:Float64),
throw(DimensionMismatch("the transpose of A has dimensions $n, $m, X has length $(length(X)) and Y has length $(length(Y))"))
end
chkstride1(A)
lda = stride(A,2)
lda >= max(1, size(A,1)) || error("`stride(A,2)` must be at least `max(1, size(A,1))`")
stride(A,2) >= size(A,1) || size(A,1) == 0 || size(A,2) <= 1 || error("`lda` must be at least `max(1, size(A,1))`")
lda = max(1, size(A,1), stride(A,2))
sX = stride(X,1)
pX = pointer(X, sX > 0 ? firstindex(X) : lastindex(X))
sY = stride(Y,1)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ Random.seed!(100)
@test_throws ErrorException BLAS.gemv(trans, view(A, 1:2:3, 1:2), view(v, 1:2))
@test_throws ErrorException BLAS.gemv(trans, view(A, 1:2, 2:-1:1), view(v, 1:2))
end
# Cases that should work despite stride(A,2) < 1
@test BLAS.gemv!('N', elty(1), zeros(elty, 0, 5), zeros(elty, 5), elty(1), zeros(elty, 0)) == elty[] # stride(A,2) == 0
@test BLAS.gemv!('N', elty(1), view(A, :, 2:-1:2), elty[3], elty(2), elty[1,2,3]) == 3.0*A[:,2] + elty[2,4,6] # stride(A,2) == -3
end
end
@testset "gemm" begin
Expand Down