JuliaSIMD / LoopVectorization.jl

Macro(s) for vectorizing loops.
MIT License
744 stars 68 forks source link

Broadcast bug #113

Open AStupidBear opened 4 years ago

AStupidBear commented 4 years ago
julia> xs = [1.9, 1.0]
2-element Array{Float64,1}:
 1.0
 1.0

julia> max_ = maximum(xs, dims=1)
1-element Array{Float64,1}:
 1.0

julia> exp_ = @avx exp.(xs .- max_)
2-element Array{Float64,1}:
 1.0               
 2.7182818284590455
chriselrod commented 4 years ago

The problem here is that broadcasting doesn't support broadcasting the first dimension yet when it isn't known that size(src,1) == 1 at compile time.

I'm not sure what the best way to support that is.

As a workaround, on master you can:

        xs = rand(T, M);
        max_ = maximum(xs, dims=1)
        @test (@avx exp.(xs .- LowDimArray{(false,)}(max_))) ≈ exp.(xs .- LowDimArray{(false,)}(max_))