Tullio.jl
Tullio.jl copied to clipboard
Accumulation and interpolation bugs
In this expression, Tullio fails to notice that the same array is being read and written into. It's happy to multi-thread over x, but the answer will depend on the order of iteration:
@tullio dt[x + 1, y] = ifelse(img[x + 1, y] == 0, 3 + dt[x, y], dt[x + 1, y])
│ begin
│ (Tullio.threader)(𝒜𝒸𝓉!, (Tullio.storage_type)(dt, img, dt), dt, tuple(img, dt), tuple(𝒶𝓍x, 𝒶𝓍y), tuple(), +, 12484, nothing)
│ dt
│ end
│ shiftedind = [:x]
│ threads = true
│ unsafeleft = Symbol[]
│ unsaferight = [:x]
I'm not sure that's supported, but an error would be better than a wrong answer.
Second, an easier bug, if we try to loop explicitly over x, it fails to remove the dollar on the left:
for x in 1:(h-1)
@tullio dt[$x + 1, y] = ifelse(img[$x + 1, y] == 0, 3 + dt[$x, y], dt[$x + 1, y])
end
# ERROR: syntax: "$" expression outside quote
│ leftraw = Any[:($(Expr(:$, :x)) + 1), :y]
│ right = :(ifelse(img[x + 1, y] == 0, 3 + dt[x, y], dt[x + 1, y]))
It works if there's no shift on the left:
for x in 2:h
@tullio dt[$x, y] = ifelse(img[$x, y] == 0, 3 + dt[$x-1, y], dt[$x, y])
end
│ leftraw = Any[:x, :y]
Not sure if this is helpful at all but something like
for x in 1:(h-1)
i = x + 1
@tullio dt[$i y] = ifelse(img[$i, y] == 0, 3 + dt[$x, y], dt[$i, y])
end
seems to fix the second problem