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

Inference failure with finaliser

Open mcabbott opened this issue 4 years ago • 1 comments

From https://discourse.julialang.org/t/fast-4d-argmax/58566, why does this make an Array{Any,3}?

julia> using Tullio

julia> fun((i,x), (j,y)) = ifelse(x>y, (i,x), (j,y));

julia> findmax4Dt(A) = @tullio (fun) out[i,j,k] := (z, A[i,j,k,z])  init = (0,-Inf);

julia> argmax4Dt(A) = @tullio (fun) out[i,j,k] := first <| (z, A[i,j,k,z])  init = (0,-Inf)  threads=false

julia> A = rand(3, 4, 1, 5);

julia> findmax4Dt(A)
3×4×1 Array{Tuple{Int64, Float64}, 3}:
[:, :, 1] =
 (2, 0.859765)  (5, 0.97632)   (4, 0.860201)  (4, 0.980509)
 (4, 0.778454)  (3, 0.974338)  (3, 0.692936)  (4, 0.866616)
 (4, 0.991605)  (2, 0.947224)  (2, 0.950299)  (3, 0.997265)

julia> argmax4Dt(A)
3×4×1 Array{Any, 3}:
[:, :, 1] =
 2  5  4  4
 4  3  3  4
 4  2  2  3

Here threads=false is to avoid #36.

mcabbott avatar Apr 04 '21 19:04 mcabbott

Because it does this, after getting Int from Core.Compiler.return_type:

julia> Base.promote_type(Int, typeof((0, -Inf)))
Any

mcabbott avatar Apr 04 '21 21:04 mcabbott