Skip to content
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

Wrong answers from dot with a SubArray that reverts the order of elements on Julia v1.6 and before #48661

Closed
junyuan-chen opened this issue Feb 13, 2023 · 1 comment
Labels
linear algebra Linear algebra
Milestone

Comments

@junyuan-chen
Copy link

I am surprised by some wrong answers from dot that are illustrated below:

julia> using LinearAlgebra

julia> v1 = [1.0, 2.0, 3.0]
3-element Vector{Float64}:
 1.0
 2.0
 3.0

julia> dot([1.0, 2.0], view(v1, 2:-1:1))
7.0

The 7.0 returned above seems like coming from a bug that computes what I would expect for dot([1.0, 2.0], view(v1, 3:-1:2)).

Such behavior is not present if the parent vector contains integers:

julia> v2 = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> dot([1.0, 2.0], view(v2, 2:-1:1))
4.0

I noticed the above unexpected results when I was trying to figure out why the CI for a package fails on Julia v1.6 for all platforms. It seems that the above behavior happens on Julia v1.6.7 and older versions but not v1.7 or later.

I am posting my local version info here but I don't think this is platform-specific:

julia> versioninfo()
Julia Version 1.6.7
Commit 3b76b25b64 (2022-07-19 15:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)
Environment:
  JULIA_NUM_THREADS = 8
@N5N3
Copy link
Member

N5N3 commented Feb 13, 2023

The neg-stride support for BLAS.dot was added in 1.7 (#39751), and #42957 extends it to more BLAS funs in 1.8.
Since #41513 was backported to 1.6. So perhaps we should also backport them.

@N5N3 N5N3 added this to the 1.6.x milestone Feb 13, 2023
@N5N3 N5N3 added the linear algebra Linear algebra label Feb 13, 2023
@vtjnash vtjnash closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

No branches or pull requests

3 participants