Tullio.jl
Tullio.jl copied to clipboard
Inference failure with finaliser
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.
Because it does this, after getting Int from Core.Compiler.return_type:
julia> Base.promote_type(Int, typeof((0, -Inf)))
Any