-
-
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: apply tmerge limit elementwise to the Union #50927
Conversation
…0929) This is the part of #50927 required to fix #49249. Specifically, before this change `tmerge(Tuple{Any, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Int}}` but `tmerge(Tuple{BIG_UNION, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Any}}`. This feels bad intuitively because giving the compiler more type information led it to forget type information that it already knew about, and is especially damaging because it led to unnecessary type instability when iterating tuples with complex element types (because the iterator state should be inferrable as an `Int` even if you have no idea what the tuple type is). This is tagged for backport to 1.10 since it is a relatively unobtrusive change and it fixes the string regression in a more proper way.
…liaLang#50929) This is the part of JuliaLang#50927 required to fix JuliaLang#49249. Specifically, before this change `tmerge(Tuple{Any, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Int}}` but `tmerge(Tuple{BIG_UNION, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Any}}`. This feels bad intuitively because giving the compiler more type information led it to forget type information that it already knew about, and is especially damaging because it led to unnecessary type instability when iterating tuples with complex element types (because the iterator state should be inferrable as an `Int` even if you have no idea what the tuple type is). This is tagged for backport to 1.10 since it is a relatively unobtrusive change and it fixes the string regression in a more proper way.
…liaLang#50929) This is the part of JuliaLang#50927 required to fix JuliaLang#49249. Specifically, before this change `tmerge(Tuple{Any, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Int}}` but `tmerge(Tuple{BIG_UNION, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Any}}`. This feels bad intuitively because giving the compiler more type information led it to forget type information that it already knew about, and is especially damaging because it led to unnecessary type instability when iterating tuples with complex element types (because the iterator state should be inferrable as an `Int` even if you have no idea what the tuple type is). This is tagged for backport to 1.10 since it is a relatively unobtrusive change and it fixes the string regression in a more proper way.
…0929) This is the part of #50927 required to fix #49249. Specifically, before this change `tmerge(Tuple{Any, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Int}}` but `tmerge(Tuple{BIG_UNION, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Any}}`. This feels bad intuitively because giving the compiler more type information led it to forget type information that it already knew about, and is especially damaging because it led to unnecessary type instability when iterating tuples with complex element types (because the iterator state should be inferrable as an `Int` even if you have no idea what the tuple type is). This is tagged for backport to 1.10 since it is a relatively unobtrusive change and it fixes the string regression in a more proper way. (cherry picked from commit 6e2e6d0)
This allows forming larger unions, as long as each element in the Union is both relatively distinct and relatively simple. For example: tmerge(Base.BitSigned, Nothing) == Union{Nothing, Int128, Int16, Int32, Int64, Int8} tmerge(Tuple{Base.BitSigned, Int}, Nothing) == Union{Nothing, Tuple{Any, Int64}} tmerge(AbstractVector{Int}, Vector) == AbstractVector Disables a test from dc8d885. Co-authored-by: Oscar Smith <[email protected]>
5c008b5
to
f4ac759
Compare
416b240
to
bae558c
Compare
@nanosoldier |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
Seems that this will eliminate an allocation in sparse matmul, but otherwise does not change anything. |
Doesn't seem to have any regressions in inference so I guess it's still worth |
The package evaluation job you requested has completed - possible new issues were detected. |
Can this be |
Yeah, that was changed in a later version of the PR at Oscar's insistence, and updated in the commit messages but not the PR text. Initially I didn't have the tname_intersection function returning the intersection, so it couldn't match up the parameters. |
This allows forming larger unions, as long as each element in the Union is both relatively distinct and relatively simple. For example: tmerge(Base.BitSigned, Nothing) == Union{Nothing, Int128, Int16, Int32, Int64, Int8} tmerge(Tuple{Base.BitSigned, Int}, Nothing) == Union{Nothing, Tuple{Any, Int64}} tmerge(AbstractVector{Int}, Vector) == AbstractVector Disables a test from dc8d885, which does not seem possible to handle currently. This makes somewhat drastic changes to make this algorithm more commutative and simpler, since we dropped the final widening to `Any`. Co-authored-by: pchintalapudi <[email protected]> Co-authored-by: Oscar Smith <[email protected]>
…0929) This is the part of #50927 required to fix #49249. Specifically, before this change `tmerge(Tuple{Any, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Int}}` but `tmerge(Tuple{BIG_UNION, Int}, Nothing)` would be `Union{Nothing, Tuple{Any, Any}}`. This feels bad intuitively because giving the compiler more type information led it to forget type information that it already knew about, and is especially damaging because it led to unnecessary type instability when iterating tuples with complex element types (because the iterator state should be inferrable as an `Int` even if you have no idea what the tuple type is). This is tagged for backport to 1.10 since it is a relatively unobtrusive change and it fixes the string regression in a more proper way. (cherry picked from commit 6e2e6d0)
This allows forming larger unions, as long as each element in the Union is both relatively distinct and relatively simple. For example: