Skip to content

IO #96

Open
Open
@kengruven

Description

@kengruven

I want to do I/O with BFloat16 values, and that doesn't seem to be supported here yet. But it looks like it could be as simple as:

Base.write(io::IO, num::BFloat16) = write(io, UInt16(reinterpret(UInt32, Float32(num)) >> 16))
Base.read(io::IO, ::Type{BFloat16})::BFloat16 = reinterpret(BFloat16, read(io, UInt16))

This seems to work for me, but I'm a total newbie at Julia, so I'm not sure this is correct, especially with regards to endianness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions