Open
Description
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
Labels
No labels