LoopVectorization.jl icon indicating copy to clipboard operation
LoopVectorization.jl copied to clipboard

Broadcast bug

Open AStupidBear opened this issue 5 years ago • 1 comments
trafficstars

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

AStupidBear avatar May 10 '20 09:05 AStupidBear

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_))

chriselrod avatar May 10 '20 10:05 chriselrod