Skip to content

InexactError when the intermediate reduction type differs from the final type #36

@disberd

Description

@disberd

I came into an InexactError error when using Tullio to perform reduction and then abs2 over complex vectors.

The MWE might be easier to explain the issue:

using FFTW, Tullio
x = rand(120) .- .5
y = rand(120) .- .5
u = rand(500) .- .5
v = rand(500) .- .5
a = rand(120)
k = 2π/.01

function tfunc(u,v,a,k,x,y)
    @tullio vals[i] := exp(im * (k * (x[j]*u[i] + y[j]*v[i]) + a[j])) |> abs2
end

tfunc(u,v,a,k,x,y)

Which results in

ERROR: LoadError: InexactError: Float64(-13.863000778992978 + 2.707549484306247im)

In my example the issue could easily be resolved by performing the abs2 directly on the vals array returned by the @tullio macro.
I briefly discussed this with @mcabbott on slack and this appears to only happen when threading is enabled in @tullio.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions