-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Background and motivation
The bfloat16 type provides the same number range as the 32-bit IEEE 754 single-precision floating point type, but with a reduced precision (24 bits -> 8 bits). This is useful for machine learning to improve memory utilization, and can be used to accelerate AI workloads via AVC-512 BP / and ARMv8.6-A instructions.
Adding this type would allow us to implement these new instructions sets, and provide a common base type for various machine learning libraries.
API Proposal
namespace System.Numerics
{
public readonly struct BFloat16
: IComparable,
IComparable<BFloat16>,
IEquatable<BFloat16>
{
public static BFloat16 Epsilon { get; }
public static BFloat16 MinValue { get; }
public static BFloat16 MaxValue { get; }
// Casting
public static explicit operator BFloat16(float value);
public static explicit operator BFloat16(double value);
public static explicit operator float(BFloat16 value);
public static explicit operator double(BFloat16 value);
// Comparison
public int CompareTo(object value);
public int CompareTo(BFloat16 value);
public static bool operator ==(BFloat16 left, BFloat16 right);
public static bool operator !=(BFloat16 left, BFloat16 right);
public static bool operator <(BFloat16 left, BFloat16 right);
public static bool operator >(BFloat16 left, BFloat16 right);
public static bool operator <=(BFloat16 left, BFloat16 right);
public static bool operator >=(BFloat16 left, BFloat16 right);
// Equality
public bool Equals(BFloat16 obj);
public override bool Equals(object? obj);
public override int GetHashCode();
// ToString override
public override string ToString();
}
}API Usage
BFloat16 bf16 = (BFloat16)1.0f; Alternative Designs
No response
Risks
No response
saucecontrol, neon-sunset, Zintom, colejohnson66, SommerEngineering and 4 moreZintom, SommerEngineering, martindevans and 4creatorsxoofx
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged