Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Metal and oneAPI when nodes are ranges #597

Open
pvillacorta opened this issue Jun 26, 2024 · 0 comments
Open

Error with Metal and oneAPI when nodes are ranges #597

pvillacorta opened this issue Jun 26, 2024 · 0 comments

Comments

@pvillacorta
Copy link

pvillacorta commented Jun 26, 2024

Hello, I am experiencing an error that can be reproduced with the following lines:

using Interpolations, CUDA, Adapt

N = 5
x = range(0f0, 1f0, N)
y = rand(Float32, N)

itp = interpolate((x,), y, Gridded(Linear()))
cuitp = adapt(CuArray{Float32}, itp);

xp = range(0f0, 1f0, N)

u = cuitp.(xp)

This works with CUDA and AMDGPU arrays but, when:

cuitp = adapt(MtlArray{Float32}, itp);

or:

cuitp = adapt(oneArray{Float32}, itp);

The following errors appear:

ERROR: LoadError: InvalidIRError: compiling MethodInstance for (::Metal.var"#broadcast_linear#202")(::Metal.MtlDeviceVector{Float32, 1}, ::Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{1, Metal.MTL.Private}, Tuple{Base.OneTo{Int64}}, Interpolations.GriddedInterpolation{Float32, 1, Metal.MtlDeviceVector{Float32, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{StepRangeLen{Float32, Float32, Float32, Int64}}}, Tuple{Base.Broadcast.Extruded{StepRangeLen{Float32, Float32, Float32, Int64}, Tuple{Bool}, Tuple{Int64}}}}) resulted in invalid LLVM IR
ERROR: LoadError: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#34#36")(::oneAPI.oneKernelContext, ::oneAPI.oneDeviceVector{Float32, 1}, ::Base.Broadcast.Broadcasted{oneAPI.oneArrayStyle{1, oneAPI.oneL0.DeviceBuffer}, Tuple{Base.OneTo{Int64}}, Interpolations.GriddedInterpolation{Float32, 1, oneAPI.oneDeviceVector{Float32, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{StepRangeLen{Float32, Float32, Float32, Int64}}}, Tuple{Base.Broadcast.Extruded{oneAPI.oneDeviceVector{Float32, 1}, Tuple{Bool}, Tuple{Int64}}}}, ::Int64) resulted in invalid LLVM IR

Full stacktrace is here.

I do not know if this is a bug from Metal and oneAPI or if it is the expected behaviour.
What is strange is the fact that it only fails for Metal and oneAPI.
Note that this works for all backends:

using Interpolations, CUDA, Adapt

N = 5
x = collect(range(0f0, 1f0, N))
y = rand(Float32, N)

itp = interpolate((x,), y, Gridded(Linear()))
cuitp = adapt(CuArray{Float32}, itp);

xp = rand(N); xp = adapt(CuArray{Float32}, xp)

u = cuitp.(xp)

But I need input nodes to be ranges instead of arrays, to avoid extra allocations.
Thank you, I really appreciate what this package offers and it would be awesome to put a solution to this 😄
Cheers,
Pablo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant