-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Implement bit manipulation API for BFloat16 #120602
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
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @dotnet/area-system-numerics |
public static BFloat16 ReadBFloat16BigEndian(ReadOnlySpan<byte> source) | ||
{ | ||
return BitConverter.IsLittleEndian ? | ||
BitConverter.Int16BitsToBFloat16(ReverseEndianness(MemoryMarshal.Read<short>(source))) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BitConverter.Int16BitsToBFloat16(ReverseEndianness(MemoryMarshal.Read<short>(source))) : | |
BitConverter.UInt16BitsToBFloat16(ReverseEndianness(MemoryMarshal.Read<ushort>(source))) : |
Should we using UInt16
everywhere to match the field type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current changes are at least consistent with ReadHalfLittleEndian
, which is implemented with Int16
even though it's field is UInt16
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I just duplicated everything from Half
.
Closes #119874.
Contains missing API in #119874 (comment). Please confirm whether it needs reiterating through API review.