Skip to content

Float64 to Float16 conversion is slow #41161

@JeffBezanson

Description

@JeffBezanson
julia> @btime Float16(rand())
  15.878 ns (0 allocations: 0 bytes)

julia> @btime Float16(Float32(rand()))
  5.928 ns (0 allocations: 0 bytes)

julia> @btime Float16(rand(Float32))
  4.282 ns (0 allocations: 0 bytes)

I believe we are calling compiler-rt for this. Of course this can't be implemented by converting via Float32 since that rounds twice, but it's frustrating that that method is so much faster. Would be nice to have a better implementation of this. See also #40315.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions