-
Notifications
You must be signed in to change notification settings - Fork 98
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
Extend parameter trait to wmetrics #150
Conversation
I think this is ready for review. As for the little regression benchmark from #107, this is what I get on this branch: julia> @btime colwise(dd, Xcol,Ycol);
798.898 μs (2 allocations: 781.33 KiB)
julia> @btime colwise_naive(Xcol,Ycol);
834.077 μs (2 allocations: 781.33 KiB) The little gap is consistent and in the "desired direction". What #135 was also doing and what is included here is fixing some length checking and return type issues for the weighted metrics. Other than that this establishes the parameter trait across all |
It would be great if we could merge these changes this time before other dramatic PRs come in. Therefore, here's a gentle "bump". |
Correct me if I am wrong but by doing stuff like:
and then dispatching on |
@KristofferC I'm not sure I understand. Currently, we have this in const metrics = (Euclidean,SqEuclidean,PeriodicEuclidean,Chebyshev,Cityblock,TotalVariation,Minkowski,Hamming,Jaccard,RogersTanimoto,CosineDist,ChiSqDist,KLDivergence,RenyiDivergence,BrayCurtis,JSDivergence,SpanNormDist,GenKLDivergence)
const UnionMetrics = Union{metrics...} and this in const weightedmetrics = (WeightedEuclidean,WeightedSqEuclidean,WeightedCityblock,WeightedMinkowski,WeightedHamming)
const UnionWeightedMetrics{W} = Union{map(M->M{W}, weightedmetrics)...} Are you proposing to replace for M in (metrics..., weightedmetrics...)
@eval @inline (dist::$M)(a::AbstractArray, b::AbstractArray) = _evaluate(dist, a, b, parameters(dist))
if M != SpanNormDist
@eval @inline (dist::$M)(a::Number, b::Number) = _evaluate(dist, a, b, parameters(dist))
end
end This is already the adopted version. |
Yeah, I'm sorry if my comment wasn't directly related to the PR but more of a comment about the current state of affairs. There is a lot of code movement here and it is a bit unclear to me what is the core change in this PR? Is it just a bug fix and the added tests fail on master? |
First of all, this PR joins the weighted metrics with the Now that I understand that your comment was not related to the actual PR, I think I understand what you mean, and I was thinking about it when I was writing the periodic distance. Should I introduce some abstract types like |
Yes, that makes sense to me.
I think that is the best. |
Bump. 😇 |
@@ -222,7 +222,7 @@ Base.@propagate_inbounds function _evaluate(d::UnionMetrics, a::AbstractArray, b | |||
@inbounds begin | |||
s = eval_start(d, a, b) | |||
if IndexStyle(a, b) === IndexLinear() || size(a) == size(b) | |||
@simd for I in 1:length(a) | |||
@simd for I in eachindex(a, b) |
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.
Note JuliaLang/julia#28226 (comment).
Is that no longer the case?
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.
I tested #150 (comment), and obtained the results above. Wasn't this the test that would determine the slowdown?
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.
Sorry, I meant #107 (comment)
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.
I get that colwise
is consistently and measurably faster than naivecolwise
in that test.
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.
I guess it is fixed then...
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.
I'll quickly double-check on Julia v1.0...
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.
Alright, I have tested my but off, and I can't seem to be able to reproduce the slowdown anymore, even on Julia v1.0. While the issue JuliaLang/julia#28226 persists even on nightlies, the issue #100 does not re-occur with this PR, neither on Julia v1.0.5 nor v1.3 or nightlies. AFAICT, we wouldn't introduce a slowdown with the change in the line commented on above.
Gentle bump. |
Bump again. I'd like to continue with the transition to |
Bumping again 🙂 What is holding this PR back? |
Gentle bump once more. |
Please, could we make some progress here? There are new PRs starting to pile up (like #161) that would make it unnecessarily tedious to merge this after those. |
This is conceptually nothing but a rebase of #135, so (almost) all the credit goes to @devmotion.
This first commit simply moves wmetrics.jl to metrics.jl, the second rearranges a few docstrings. Functional changes start only in commit 3.
EDIT: Closes #135, but we should have @devmotion as a co-author.