-
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
Conversation
ret = sum( Lambdas.*dμ ) | ||
return ret | ||
# ret = sum( Lambdas.*dμ ) | ||
r = map((mu, lam) -> diffop(μ[], mu) * lam, mus, Lambdas) |
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
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
ExtrinsicEstimation
should usually be the fastest way to compute mean
. It doesn't work well for some manifolds but for Lie groups it is worth trying out when you prefer speed over accuracy.
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
ExtrinsicEstimation
gives an error:
MethodError: no method matching get_embedding(::GroupManifold{ℝ, ProductManifold{ℝ, Tuple{TranslationGroup{ManifoldsBase.TypeParameter{Tuple{2}}, ℝ}, SpecialOrthogonal{ManifoldsBase.TypeParameter{Tuple{2}}}}}, Manifolds.SemidirectProductOperation{RotationAction{LeftAction, TranslationGroup{ManifoldsBase.TypeParameter{Tuple{2}}, ℝ}, SpecialOrthogonal{ManifoldsBase.TypeParameter{Tuple{2}}}}}})
Don't worry about it now though. I think there are other optimizations that will make a bigger difference.
Codecov Report
@@ Coverage Diff @@
## master #261 +/- ##
==========================================
- Coverage 54.14% 54.09% -0.06%
==========================================
Files 18 18
Lines 905 904 -1
==========================================
- Hits 490 489 -1
Misses 415 415
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
fg = generateGraph_Hexagonal()
@time solveGraph!(fg; multithread=true)
# 2.072770 seconds (16.03 M allocations: 742.617 MiB, 4.83% gc time)
@time solveGraph!(fg)
# 4.217847 seconds (15.65 M allocations: 717.741 MiB, 5.96% gc time) |
ret = sum( Lambdas.*dμ ) | ||
return ret | ||
# ret = sum( Lambdas.*dμ ) | ||
r = map((mu, lam) -> diffop(μ[], mu) * lam, mus, Lambdas) |
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
No description provided.