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

median and median! are type unstable for floats other than Float64 #29900

Closed
galenlynch opened this issue Nov 2, 2018 · 2 comments
Closed

median and median! are type unstable for floats other than Float64 #29900

galenlynch opened this issue Nov 2, 2018 · 2 comments

Comments

@galenlynch
Copy link
Contributor

On Julia 1.0.1 official, median appears to be type unstable for Float32 inputs. I'm not sure if this is actually a problem.

julia> @code_warntype median(rand(Float32, 3))
Body::Union{Float32, Float64}
750 1%1 = Statistics.:(:)::Core.Compiler.Const(Colon(), false)                                                                                                                                  │ 
    │   %2 = invoke Statistics._median(_2::Array{Float32,1}, %1::Colon)::Union{Float32, Float64}                                                                                                   │╻ #median#44
    └──      return %2
julia> @code_warntype median!(rand(Float32, 3))
Body::Union{Float32, Float64}
...
@StefanKarpinski
Copy link
Sponsor Member

Good catch! Should definitely be fixed. Even if the compiler is smart enough that this isn't a total performance tragedy anymore, there's no reason for a spurious type instabilities like this and we do want to make sure that the result type is fully predictable.

@galenlynch
Copy link
Contributor Author

Wow that was fast! Thanks!

KristofferC pushed a commit that referenced this issue Nov 12, 2018
KristofferC pushed a commit that referenced this issue Dec 12, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
KristofferC pushed a commit that referenced this issue Feb 20, 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

No branches or pull requests

2 participants