Skip to content

Conversation

mcabbott
Copy link
Contributor

This simply makes the complete sum of a BroadcastArray call sum(A,dims=1:N) as this seems to be faster. For example, without this PR:

julia> using LazyArrays, BenchmarkTools

julia> A = rand(100,100); B = rand(100); C = rand(100);

julia> @btime sum($A .* $B .* $C')
  5.316 μs (2 allocations: 78.20 KiB)
1220.0468263958778

julia> @btime sum(BroadcastArray(*, $A, $B, $C'))
  26.259 μs (11 allocations: 256 bytes)
1220.046826395877

julia> @btime sum(BroadcastArray(*, $A, $B, $C'), dims=(1,2))
  3.062 μs (12 allocations: 416 bytes)
1×1 Array{Float64,2}:
 1220.0468263958776

Another example in #16. That issue also has a puzzle about B' vs reshape(B,1,:) which this does nothing about.

@codecov-io
Copy link

codecov-io commented Jan 23, 2019

Codecov Report

Merging #18 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #18      +/-   ##
=========================================
+ Coverage   49.74%   49.8%   +0.06%     
=========================================
  Files          11      11              
  Lines         782     783       +1     
=========================================
+ Hits          389     390       +1     
  Misses        393     393
Impacted Files Coverage Δ
src/lazybroadcasting.jl 45.83% <100%> (+2.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4559ba2...5c99cbb. Read the comment docs.

@dlfivefifty dlfivefifty merged commit 5d9754a into JuliaArrays:master Jan 24, 2019
@mcabbott mcabbott mentioned this pull request Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants