-
Notifications
You must be signed in to change notification settings - Fork 28
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
Speed of sum(BroadcastArray) #16
Comments
Happy to accept a PR fixing this! |
Will do. But first, one more puzzle which just bit me: why is the first of these 5x quicker?
Same times here:
|
I looked at the profile and the second one spends more time in |
Thanks for taking a look, it is indeed strange. The biggest difference in an isolated getindex I can see is... far from a factor of 5:
|
Remember order of access of data makes a big difference, but I’m not sure how to test that |
Yes that could be what's happening. I was trying to dig into what
The fast one ends with this, the slow one is the same but skips the lines starting 23.0:
|
Ohhhhh, the answer is simple! |
But if I set I also just tried making all three factors different random numbers, but one adjointed, one reshaped. And the speed difference is the same. |
Hmm, you are right. Here's another data point: V4 = Base.ReshapedArray(V, (1, 500), ())
@time sum(BroadcastArray(*, V, V4, V3), dims=(2,3)); # 0.132 seconds |
BTW, I just saw JuliaLang/julia#30973 and wonder if that issue (28126) might be what is going on here. Haven't tried it out yet. |
Can we close this? |
I remain puzzled by the |
Here's something I was trying to do recently, to avoid materializing a huge array just to sum it:
Might it be worth making
sum()
simply call thedims=...
version here?Before I saw this package I was messing around with broadcasting to do this by hand, and could get in the ballpark of 0.014s here, but no better. Doing that seems likely to be more fragile.
The text was updated successfully, but these errors were encountered: