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

Type instability in hessian when interpolating a 3D field #469

Closed
touste opened this issue Dec 13, 2021 · 4 comments · Fixed by #472
Closed

Type instability in hessian when interpolating a 3D field #469

touste opened this issue Dec 13, 2021 · 4 comments · Fixed by #472

Comments

@touste
Copy link

touste commented Dec 13, 2021

Hi, see the following MWE:

using Interpolations
nx = 5
A = rand(Float64, nx, nx, nx) * 100
itp = interpolate(A, BSpline(Quadratic(Reflect(OnCell()))))
@code_warntype Interpolations.hessian(itp, 1., 1., 1.)

This gives a type instability on the wis variable:
wis::Tuple{Tuple{Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}}, Tuple{Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}}, Tuple{Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}}, Tuple{Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}}, Tuple{Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}, Interpolations.WeightedAdjIndex{3, Float64}}, Vararg{Any}}

This in turn leads to a return type Any for the function.

@touste touste changed the title Type instability in hessian when interpolation a 3D field Type instability in hessian when interpolating a 3D field Dec 13, 2021
@mkitti
Copy link
Collaborator

mkitti commented Dec 14, 2021

See JuliaLang/julia#43368

@touste
Copy link
Author

touste commented Dec 14, 2021

Are you sure this is related? I see the same issue in 1.6.4 and 1.5.4

@touste
Copy link
Author

touste commented Dec 14, 2021

That was fast! Thank you very much for fixing this.

@N5N3
Copy link
Contributor

N5N3 commented Dec 14, 2021

Well, the above fix seems only work for 3d case. Some more effort is needed.
Has been extended to 7d, should be enough for most cases.

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

Successfully merging a pull request may close this issue.

3 participants