-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Preserve structured matrix types more often when broadcasting #32762
Conversation
e11de48
to
9c7db21
Compare
Let's re-run CI and get this in. |
Interesting — the 32 bit failures look related. I don't see any differences in the printout below, but I think the
|
@mbauman Could you rebase this PR? The last CI failures look weird, and partly unrelated. Would be nice to see if those issues have been resolved meanwhile, so we could get this in. |
9c7db21
to
40624dd
Compare
Bah, now it passes tests? Looks like this is a failure that depends upon the RNG seed — likely due to differences between BLAS' exponentiation and the structured optimization. We're probably within an ULP or two. I suppose I'll just make those |
Wait that makes no sense. We're not hitting BLAS in any case here. Not sure where a difference would come in. |
Could it be that it has to do with very small numbers getting squared and getting even smaller? It has to be somehow related to the relative accuracy, I guess. What if you define D = Diagonal(rand(N).+1) or D = Diagonal(rand(-10:10, N)) ? |
This is fun: julia> two = 2
2
julia> x = 0.9390576568834563
0.9390576568834563
julia> x ^ 2
0.8818292829514472
julia> x ^ two
0.8818292829514471 Edit: looks like the difference is between using LLVM's julia> @code_llvm Base.literal_pow(^, x, Val(2))
; @ intfuncs.jl:244 within `literal_pow'
define double @julia_literal_pow_19302(double) {
top:
; ┌ @ float.jl:405 within `*'
%1 = fmul double %0, %0
; └
ret double %1
}
julia> @code_llvm x^2
; @ math.jl:860 within `^'
define double @"julia_^_19325"(double, i64) {
top:
; ┌ @ float.jl:60 within `Float64'
%2 = sitofp i64 %1 to double
; └
%3 = call double @llvm.pow.f64(double %0, double %2)
ret double %3
} |
Which one corresponds to which? |
The primary motivation here is exponentiation (fixes #32759). Previously `X .^ 2` would return a Matrix but `two=2; X .^ two` would return the same structured matrix type as `X`. This simply teaches LinearAlgebra a little bit more about broadcast so it can safely compute the zero-preservation property of broadcasts involving `Ref`s, which is sufficient to handle the literal pow argument list.
a765134
to
4705998
Compare
The failure is in |
Since #34863 got in first, I think we should drop its workaround commit from here. |
Oh yea, you mean the "fine-grained tests" thing? |
4705998
to
267f444
Compare
Sure, that one too. There had also been another commit that completely avoided looking at numeric equality between |
The primary motivation here is exponentiation (fixes #32759). Previously
X .^ 2
would return a Matrix buttwo=2; X .^ two
would return the same structured matrix type asX
. This simply teaches LinearAlgebra a little bit more about broadcast so it can safely compute the zero-preservation property of broadcasts involvingRef
s, which is sufficient to handle the literal pow argument list.