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

Fix inference precision regression for functions returning PartialStruct #38731

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

Keno
Copy link
Member

@Keno Keno commented Dec 6, 2020

Consider the included test case:

f_partial_struct_constprop(a, b) = (a[1]+b[1], 2)
g_partial_struct_constprop() = Val{f_partial_struct_constprop((1,), (1,))[1]}()

The function f_partial_struct_constprop used to infer to Tuple{Int, Int}
be eligible for constprop and then get improved to Const((2,2)). However,
at some point we sharpened the original inference to PartialStrict((::Int, 2)),
which caused an early-out that prevented the consideration of this method
for constant propagation purposes, regressing the overall inference result
to Tuple{Int, Int}. Fix that by allowing PartialStruct to pass through
the early out. I'm not seeing any impact on inference times.

Consider the included test case:
```
f_partial_struct_constprop(a, b) = (a[1]+b[1], 2)
g_partial_struct_constprop() = Val{f_partial_struct_constprop((1,), (1,))[1]}()
```

The function `f_partial_struct_constprop` used to infer to `Tuple{Int, Int}`
be eligible for constprop and then get improved to `Const((2,2))`. However,
at some point we sharpened the original inference to `PartialStrict((::Int, 2))`,
which caused an early-out that prevented the consideration of this method
for constant propagation purposes, regressing the overall inference result
to `Tuple{Int, Int}`. Fix that by allowing `PartialStruct` to pass through
the early out. I'm not seeing any impact on inference times.
@Keno Keno closed this Dec 7, 2020
@Keno Keno reopened this Dec 7, 2020
@Keno Keno closed this Dec 7, 2020
@Keno Keno reopened this Dec 7, 2020
@Keno Keno merged commit 5e048f3 into master Dec 7, 2020
@Keno Keno deleted the kf/fixinfprecregression branch December 7, 2020 19:24
aviatesk added a commit to aviatesk/JET.jl that referenced this pull request Dec 8, 2020
aviatesk added a commit to aviatesk/JET.jl that referenced this pull request Dec 9, 2020
aviatesk added a commit to aviatesk/JET.jl that referenced this pull request Dec 9, 2020
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 this pull request may close these issues.

2 participants