-
-
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
is Float16 a real computational type or not? #5942
Comments
I've wondered about this as well. Until extremely recently, we've had some tests for linear algebra over |
I saw your last comment about this and I am preparing to remove the |
I think it should have the same status as other numeric types that lack
|
Oh and fixed point would be another type in this category, though it is
|
It's very plausible in some domains, but these are also places you are unlikely to get the Julia runtime to work. |
Is that a challenge? :-)
|
Currently the fallbacks for transcendental functions look like
How about we use instead
Then we could remove most of the definitions in |
This seems to work.
|
julia> typeof(float16(1.0)*true)
Float32
julia> promote_type(Bool, Float16)
Float32 |
With the proposed fallbacks:
|
Implements @JeffBezanson's suggestion in #5942. - Removes Complex32 definitions in float16.jl - Removes also error-raising ($f)(x::FloatingPoint) fallbacks in math.jl Status: - Some of the complex functions are no longer type stable because float16(1) * im returns a Complex64 instead of the expected Complex32.
I guess there is a case to be made that any operation on |
Fair enough, but having to explicitly recast the complex elementary functions strikes me as really quite inelegant, given the generic implementations in julia> for f in (sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, exp, log, sqrt)
x=float16(rand()+rand()*im); @show f, typeof(f(x))
end
(f,typeof(f(x))) => (sin,Complex{Float16})
(f,typeof(f(x))) => (cos,Complex{Float16})
(f,typeof(f(x))) => (tan,Complex{Float32})
(f,typeof(f(x))) => (asin,Complex{Float32})
(f,typeof(f(x))) => (acos,Complex{Float32})
(f,typeof(f(x))) => (atan,Complex{Float32})
(f,typeof(f(x))) => (sinh,Complex{Float16})
(f,typeof(f(x))) => (cosh,Complex{Float16})
(f,typeof(f(x))) => (tanh,Complex{Float32})
(f,typeof(f(x))) => (asinh,Complex{Float32})
(f,typeof(f(x))) => (acosh,Complex{Float32})
(f,typeof(f(x))) => (atanh,Complex{Float32})
(f,typeof(f(x))) => (exp,Complex{Float16})
(f,typeof(f(x))) => (log,Complex{Float32})
(f,typeof(f(x))) => (sqrt,Complex{Float32}) |
Implements @JeffBezanson's suggestion in #5942. - Removes Complex32 definitions in float16.jl - Removes also error-raising ($f)(x::FloatingPoint) fallbacks in math.jl Status: - Some of the complex functions are no longer type stable because float16(1) * im returns a Complex64 instead of the expected Complex32.
Implements @JeffBezanson's suggestion in #5942. - Removes Complex32 definitions in float16.jl - Removes also error-raising ($f)(x::FloatingPoint) fallbacks in math.jl Status: - Some of the complex functions are no longer type stable because float16(1) * im returns a Complex64 instead of the expected Complex32.
The advantage of this definition is that float16(1)*im will be a Complex32 and not a Complex64. Ref: #5942
The advantage of this definition is that float16(1)*im will be a Complex32 and not a Complex64. Ref: #5942
It's resolved at this point that Float16 is a real computational type: many people want to use if for a variety of purposes and find it frustrating that it doesn't behave the same way as Float32 and Float64; moreover, GPUs have actual support for using Float16 as a computational type. |
What if anything is left to do here? |
ping @vchuravy for your thoughts |
There are two main things currently missing.
|
Both of those affect performance but not functions right? |
Yes, but if we actually want to make use of |
Strict performance improvements can happen any time and be backported, so that makes this not a release-blocking issue – it's an issue that anyone who wants to can tackle whenever. |
The build system changes and library restructuring to integrate compiler-rt and the rtlib julep are probably too big to backport, but they're making progress. |
Closing since there seem to be no more semantic changes needed. |
At this point, Float16 is in a kind of weird limbo where it is sort of a storage type but we keep haphazardly adding more and more functionality to it. I think we really need to figure out where to draw the line here. Either we severely limit the scope of Float16's functionality and stop using it in tests for anything but converting to and from other numeric types, or we just go full throttle and make it a full computation type with as much functionality as Float32 or Float64 – albeit slower, since many operations will not be implemented as native machine ops.
The text was updated successfully, but these errors were encountered: