-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Inference/constant propagation regression in Julia 1.7 #43368
Comments
Optimization isn't able to derive new inter-procedural information like this (return type), so it seems to be a regression in inference. Will look into this when I have time. |
Replacing ndims(::Type{AbstractInterpolation{T,N,IT}}) where {T,N,IT<:DimSpec{InterpolationType}} = N
ndims(::Type{ITP}) where {ITP<:AbstractInterpolation} = ndims(supertype(ITP)) with ndims(::Type{<:AbstractInterpolation{T,N,<:DimSpec{InterpolationType}}}) where {T,N} = N could fix it. julia> t = typeof(etp)
Interpolations.FilledExtrapolation{Float64, 1, Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Constant{Nearest, Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, BSpline{Constant{Nearest, Throw{OnGrid}}}, Float64}
julia> t = supertype(t)
AbstractExtrapolation{Float64, 1, Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Constant{Nearest, Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, BSpline{Constant{Nearest, Throw{OnGrid}}}}
julia> t = supertype(t)
Interpolations.AbstractInterpolationWrapper{Float64, 1, Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Constant{Nearest, Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, BSpline{Constant{Nearest, Throw{OnGrid}}}}
julia> t = supertype(t)
AbstractInterpolation{Float64, 1, BSpline{Constant{Nearest, Throw{OnGrid}}}} So this seems also related with the type-more-complex check? |
Bisected to:
|
MWE: abstract type e{a,j} <: AbstractArray{a,j} end
abstract type b{a,j,c,d} <: e{a,j} end
struct h{a,j,f,d,i} <: b{a,j,f,d} end
Base.ndims(::Type{f}) where f<:e = ndims(supertype(f))
Base.ndims(g::e) = ndims(typeof(g))
Base.return_types(ndims, (h{Any, 0, Any, Int64, Any},)) Int64 on 1.6, Any on 1.7 |
Note that OP is fixed, due to changes to ndims, but the MWE above still works. |
We had a special case for Type that disallowed type trait recursion in favor of a pattern that almost never appears in code (only once in the compiler by accident where it doesn't matter). This was unnecessarily confusing and unexpected to predict what can infer, and made traits harder than necessary (such as Broadcast.ndims since 70fc3cd). Fix #43296 Fix #43368
We had a special case for Type that disallowed type trait recursion in favor of a pattern that almost never appears in code (only once in the compiler by accident where it doesn't matter). This was unnecessarily confusing and unexpected to predict what can infer, and made traits harder than necessary (such as Broadcast.ndims since 70fc3cd). Fix #43296 Fix #43368
We had a special case for Type that disallowed type trait recursion in favor of a pattern that almost never appears in code (only once in the compiler by accident where it doesn't matter). This was unnecessarily confusing and unexpected to predict what can infer, and made traits harder than necessary (such as Broadcast.ndims since 70fc3cd). Fix #43296 Fix #43368
We had a special case for Type that disallowed type trait recursion in favor of a pattern that almost never appears in code (only once in the compiler by accident where it doesn't matter). This was unnecessarily confusing and unexpected to predict what can infer, and made traits harder than necessary (such as Broadcast.ndims since 70fc3cd). Fix #43296 Fix #43368 (cherry picked from commit 33e3d9f)
We had a special case for Type that disallowed type trait recursion in favor of a pattern that almost never appears in code (only once in the compiler by accident where it doesn't matter). This was unnecessarily confusing and unexpected to predict what can infer, and made traits harder than necessary (such as Broadcast.ndims since 70fc3cd). Fix #43296 Fix #43368 (cherry picked from commit 33e3d9f)
I've run into a problem that affects Interpolations.jl. Type inference (or more likely constant propagation?) in Julia 1.7.0 gives up earlier than in previous versions of Julia.
Fairly minimal example:
With the result:
While for example using Julia 1.6.1:
Forcing specialization for one more method of
ndims
solves the problem but I don't know if this is the right solution.Versioninfo for reference:
ref: JuliaMath/Interpolations.jl#468
The text was updated successfully, but these errors were encountered: