-
-
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
simplify norm computations. #43190
simplify norm computations. #43190
Conversation
They are also now about 2x faster.
|
Does |
No. Is the intended behavior that |
Makes sense. PR updated. Performance is still improved by the same amount. |
y === nothing && break | ||
(v, s) = y | ||
vnorm = norm(v) | ||
minabs = ifelse(isnan(minabs) | (minabs < vnorm), minabs, vnorm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KristofferC is this good to merge? |
Maybe @stevengj wants to take a look since he did a lot of this originally. But to me it seems OK at least. |
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. |
stdlib/LinearAlgebra/src/generic.jl
Outdated
end | ||
return convert(T, sum) | ||
end | ||
generic_norm1(x) = mapreduce(norm, +, x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we lose much accuracy here since we are no longer accumulating the sum in at least double precision?
Should be fine, I hope, since the sum is always well-conditioned (being of nonnegative quantities)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this new behavior is reasonable. Especially since norm(Array{BlasReal, N}, 1)
will go to BLAS anyway.
Nanosoldier has a couple fails, but none of them look related. |
Which logs did you look at?? IntensityMetrics, MRphy, Transparency, Distances, Unitful, are clearly related? They all error in TaylorModels must also be related, errors after a normInf call (although perhaps just a too tight tolerance on the check). DynamicalSystemsBase and KissMCMC are most likely also related, but might also be just too tight of a tolerance. |
The IntensityMetrics, MRphy, Transparency, Distances, and Unitful are all erroring in |
So these failures that come specifically from @nanosoldier |
I'll admit, it seems a little suss, but I looked fairly carefully, and can't see any possible connection... |
julia/stdlib/LinearAlgebra/src/generic.jl Line 625 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 628 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 559 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 497 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 498 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 501 in b9378fd
julia/stdlib/LinearAlgebra/src/generic.jl Line 510 in b9378fd
|
@fredrikekre Good catch! Thanks. This should fix it (although I should probably add a tests for this case to Base). |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. |
That looks a lot better. The TaylorModels failure looks related, but I don't understand how there could be a difference in the result. |
Probably still a good idea? |
Interestingly, this silently allows handling of |
@KristofferC LinearAlgebra seems to believe that for numbers, |
@oscardssmith, see the discussion in JuliaLang/LinearAlgebra.jl#804. |
In that case, I don't think I'll add a test since it's unclear what behavior we actually want. I've filed PainterQubits/Unitful.jl#500 which will make it so LinearAlgebra and Unitful agree which seems like a good thing. |
I'm planning on merging Monday sans objections. |
Something like this, BTW, could help extend the (silent) handling of function generic_norm2(x)
maxabs = normInf(x)
(ismissing(maxabs) || maxabs == 0 || isinf(maxabs)) && return maxabs
T = typeof(maxabs)
if isfinite(length(x)*maxabs*maxabs) && maxabs*maxabs != 0 # Scaling not necessary
return convert(T, sqrt(mapreduce(norm_sqr, +, x; init=zero(promote_type(Float64, T)))))
else
return convert(T, maxabs*sqrt(mapreduce(v -> abs2(norm(v)/maxabs), +, x; init=zero(promote_type(Float64, T)))))
end
end
|
looks good. I'll make sure performance is good, and put it in a follow-up PR. |
@dkarrasch is the |
My (first) approach was a 1-1 "translation" of the current implementation, keeping all the type stuff in. Yes, the next step would be to further simplify and improve, if possible. |
* simplify norm computations.
* simplify norm computations.
They are also now about 2x faster.