I said I'd try to narrow down some of the errors from mcabbott/Tullio.jl#57. Here's a start:
A max gradient:
# @tullio (max) X[i] := D[i,j] verbose=1 # MethodError: no method matching instruction!(::LoopVectorization.LoopSet, ::typeof(zero))
@macroexpand @avx for i = 𝒶𝓍i # works fine!
done = 0
for j = 𝒶𝓍j
peak = onlyone(ℛ[i, 1] == D[i, j], done)
begin
ℰ𝓍1 = zero(𝒯)
ℰ𝓍2 = ifelse(𝓇𝒽𝓈⛰, 𝛥ℛ[i, 1], ℰ𝓍1)
𝛥D[i, j] += ℰ𝓍2
end
done += anyone(peak)
end
end;
@macroexpand @avx for i = 𝒶𝓍i # LoadError: type Expr has no field value
done = 0
for j = 𝒶𝓍j
peak = $(Tullio.onlyone)(ℛ[i, 1] == D[i, j], done)
begin
ℰ𝓍1 = $zero(𝒯)
ℰ𝓍2 = $ifelse(𝓇𝒽𝓈⛰, 𝛥ℛ[i, 1], ℰ𝓍1)
𝛥D[i, j] += ℰ𝓍2
end
done += $anyone(peak)
end
end;
# But those aren't the same error. Here's the exact expression:
lex2 = quote
local #= /Users/me/.julia/dev/Tullio/src/macro.jl:1087 =# @inline(function ∇𝒜𝒸𝓉!(::Type{<:Array{<:Union{Base.HWReal, Bool}}}, 𝛥D, 𝛥ℛ::AbstractArray{𝒯}, ℛ, D, 𝒶𝓍i, 𝒶𝓍j, ♻=nothing) where {𝒯}
#= /Users/me/.julia/dev/Tullio/src/macro.jl:1091 =# LoopVectorization.@avx unroll = 0 for i = 𝒶𝓍i
begin
🆗𝓇𝒽𝓈 = 0
for j = 𝒶𝓍j
begin
𝓇𝒽𝓈⛰ = Tullio.onlyone(ℛ[i] == D[i, j], 🆗𝓇𝒽𝓈)
begin
ℰ𝓍1 = $(zero)(𝒯)
ℰ𝓍2 = $(ifelse)(𝓇𝒽𝓈⛰, 𝛥ℛ[i], ℰ𝓍1)
𝛥D[i, j] += ℰ𝓍2
end
🆗𝓇𝒽𝓈 += Tullio.anyone(𝓇𝒽𝓈⛰)
end
end
nothing
end
end
nothing
end)
end;
macroexpand(Main, lex2) # LoadError: MethodError: no method matching instruction!(::LoopVectorization.LoopSet, ::typeof(zero))
And a convolution:
# @tullio y[i] := x[pad(i-a, 3)] * k[a] verbose=1 # LoadError: "Don't know how to handle expression."
@macroexpand @avx for i in 1:100 # fine!
acc = 0.0
for a in 1:7
acc = acc + (
(i - a >= first(axes(x, 1))) & (i - a <= last(axes(x, 1))) ?
x[i - a] :
zero(eltype(x))
) * k[a]
end
y[i] = acc
end;
@macroexpand @avx for i in 1:100 # fails "LoadError: type Symbol has no field value"
acc = 0.0
for a in 1:7
acc = acc + (
(i - a >= $first(axes(x, 1))) & (i - a <= last(axes(x, 1))) ?
x[i - a] :
zero(eltype(x))
) * k[a]
end
y[i] = acc
end;
@macroexpand @avx for i in 1:100 # fails
acc = 0.0
for a in 1:7
acc = acc + (
(i - a >= $first($axes(x, 1))) & (i - a <= $last($axes(x, 1))) ?
x[i - a] :
$zero($eltype(x))
) * k[a]
end
y[i] = acc
end;
# But the real error comes from the gradient.
# And this is a little different, perhaps no wonder it complains:
lex1 = quote
local #= /Users/me/.julia/dev/Tullio/src/macro.jl:1087 =# @inline(function ∇𝒜𝒸𝓉!(::Type{<:Array{<:Union{Base.HWReal, Bool}}}, 𝛥x, 𝛥k, 𝛥ℛ::AbstractArray{𝒯}, ℛ, x, k, 𝒶𝓍a, 𝒶𝓍i, ♻=nothing) where {𝒯}
#= /Users/me/.julia/dev/Tullio/src/macro.jl:1091 =# LoopVectorization.@avx unroll = 0 for a = 𝒶𝓍a
begin
nothing
for i = 𝒶𝓍i
begin
ℰ𝓍1 = conj(k[a])
ℰ𝓍2 = 𝛥ℛ[i] * ℰ𝓍1
ℰ𝓍3 = conj(if (i - a >= first(axes(x, 1))) & (i - a <= Base.last(axes(x, 1)))
x[i - a]
else
zero(eltype(x))
end)
ℰ𝓍4 = 𝛥ℛ[i] * ℰ𝓍3
if (i - a >= first(axes(𝛥x, 1))) & (i - a <= last(axes(𝛥x, 1)))
# NB it writes inside the if statement.
𝛥x[i - a] = 𝛥x[i - a] + ℰ𝓍2
else
zero(eltype(𝛥x))
end
𝛥k[a] = 𝛥k[a] + ℰ𝓍4
end
end
nothing
end
end
nothing
end)
end;
macroexpand(Main, lex1) # LoadError: "Don't know how to handle expression."
I said I'd try to narrow down some of the errors from mcabbott/Tullio.jl#57. Here's a start:
A
maxgradient:And a convolution: