-
Notifications
You must be signed in to change notification settings - Fork 4
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
Less allocs in resid2DLinear and faster mean #261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ | |
|
||
|
||
function resid2DLinear(μ, mus, Lambdas; diffop::Function=-) # '-' exploits EuclideanManifold commutativity a-b = b-a | ||
dμ = broadcast(diffop, μ, mus) # mus .- μ ## μ .\ mus | ||
# dμ = broadcast(diffop, μ, mus) # mus .- μ ## μ .\ mus | ||
# @show round.(dμ, digits=4) | ||
ret = sum( Lambdas.*dμ ) | ||
return ret | ||
# ret = sum( Lambdas.*dμ ) | ||
r = map((mu, lam) -> diffop(μ[], mu) * lam, mus, Lambdas) | ||
return sum(r) | ||
end | ||
|
||
function solveresid2DLinear!(res, x, mus, Lambdas; diffop::Function=-)::Nothing | ||
|
@@ -71,7 +72,7 @@ function _getManifoldFullOrPart(mkd::ManifoldKernelDensity, aspartial::Bool=true | |
end | ||
|
||
function Statistics.mean(mkd::ManifoldKernelDensity, aspartial::Bool=true; kwargs...) | ||
return mean(_getManifoldFullOrPart(mkd,aspartial), getPoints(mkd, aspartial); kwargs...) | ||
return mean(_getManifoldFullOrPart(mkd,aspartial), getPoints(mkd, aspartial), GeodesicInterpolation(); kwargs...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GeodesicInterpolation is currently way faster but still has dynamic dispatch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I'll give it a try. With all the performance enhancements you helped with so far we are seeing a major improvement already. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! Feel free to report any further issues you think I could help with. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Don't worry about it now though. I think there are other optimizations that will make a bigger difference. |
||
end | ||
""" | ||
$SIGNATURES | ||
|
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.
@dehann, here is a version without the extra dispatch and allocations.
Is μ always of length 1?
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 think so, will double check bit later today.
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.
looks right