-
-
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
Regression of inferrability of broadcast code #51129
Labels
broadcast
Applying a function over a collection
compiler:inference
Type inference
regression
Regression in behavior compared to a previous version
Milestone
Comments
giordano
added
regression
Regression in behavior compared to a previous version
broadcast
Applying a function over a collection
compiler:inference
Type inference
labels
Aug 31, 2023
Apparently inference cannot deal with the ntuple version of this, since it sees confusing recursion in the abstractinterpretation, so it doesn't attempt to constprop the values for diff --git a/base/broadcast.jl b/base/broadcast.jl
index fd330a7f2c..43044f9b7d 100644
--- a/base/broadcast.jl
+++ b/base/broadcast.jl
@@ -714,8 +714,8 @@ _broadcast_getindex_eltype(A) = eltype(A) # Tuple, Array, etc.
eltypes(::Tuple{}) = Tuple{}
eltypes(t::Tuple{Any}) = Iterators.TupleOrBottom(_broadcast_getindex_eltype(t[1]))
eltypes(t::Tuple{Any,Any}) = Iterators.TupleOrBottom(_broadcast_getindex_eltype(t[1]), _broadcast_getindex_eltype(t[2]))
-# eltypes(t::Tuple) = (TT = eltypes(tail(t)); TT === Union{} ? Union{} : Iterators.TupleOrBottom(_broadcast_getindex_eltype(t[1]), TT.parameters...))
-eltypes(t::Tuple) = Iterators.TupleOrBottom(ntuple(i -> _broadcast_getindex_eltype(t[i]), Val(length(t)))...)
+eltypes(t::Tuple) = (TT = eltypes(tail(t)); TT === Union{} ? Union{} : Iterators.TupleOrBottom(_broadcast_getindex_eltype(t[1]), TT.parameters...))
+# eltypes(t::Tuple) = Iterators.TupleOrBottom(ntuple(i -> _broadcast_getindex_eltype(t[i]), Val(length(t)))...)
# Inferred eltype of result of broadcast(f, args...)
function combine_eltypes(f, args::Tuple) |
N5N3
pushed a commit
that referenced
this issue
Sep 3, 2023
KristofferC
pushed a commit
that referenced
this issue
Sep 15, 2023
nalimilan
pushed a commit
that referenced
this issue
Nov 5, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
broadcast
Applying a function over a collection
compiler:inference
Type inference
regression
Regression in behavior compared to a previous version
In v1.10.0-beta2 I get
Return type of
f
is inferred asUnion{Vector, BitVector}
, but I'm missing how this can be aBitVector
at all.Interestingly, if I change the definition of
f
tof(v, x) = ((v ./ x) .^ 2)
and then change back tof(v, x) = (1 .- (v ./ x) .^ 2)
then this is inferred correctly asVector{Float64}
:The fact that this depends on previous definitions of the function is quite surprising.
In 1.9.3 I get out-of-the-box the return type
Vector{Float64}
as expected.
The text was updated successfully, but these errors were encountered: