Contributors
-
Tobias Hector, AMD
-
Stu Smith, AMD
-
Jeff Bolz, Nvidia
-
Kévin Petit, Arm
-
David Neto, Google
-
Graeme Leese, Broadcom
-
Ruihao Zhang, Qualcomm
-
Mark Sheppard, Imagination
-
Ben Ashbaugh, Intel
-
Dmitry Sidorov, Intel
-
Victor Mustya, Intel
-
Alan Baker, Google
Notice
Copyright (c) 2023-2025 The Khronos Group Inc. Copyright terms at http://www.khronos.org/registry/speccopyright.html
Status
-
Approved by the SPIR-V Working Group: 2025-01-29
-
Approved by the Khronos Board of Promoters: 2025-03-14
Dependencies
This extension is written against the SPIR-V Specification, Version 1.6 Revision 4.
This extension requires SPIR-V 1.0.
This extension interacts with SPV_KHR_cooperative_matrix.
Overview
This extension extends the OpTypeFloat instruction to enable the use of bfloat16 types with cooperative matrices and dot products, and enabling conversions between other types.
Extension Name
To use this extension within a SPIR-V module, the following OpExtension must be present in the module:
OpExtension "SPV_KHR_bfloat16"
Modifications to the SPIR-V Specification, Version 1.6
FP Encoding
Add a new enum:
| FP Encoding | Width(s) | Enabling Capabilities | |
|---|---|---|---|
0 |
BFloat16KHR - bias is 127
The additional precision parameters p and emax are calculated as p = t+1 and emax = bias.
The radix (or base) b is 2. |
16 |
BFloat16TypeKHR |
Type-Declaration Instructions
Add the following requirement to OpTypeCooperativeMatrixKHR:
If Component Type has a *BFloat16KHR* encoding then *BFloat16CooperativeMatrixKHR* must be declared.
Conversion Instructions
Add the following paragraph to OpFConvert, OpConvertFToU, OpConvertFToS, OpConvertSToF, and OpConvertUToF:
Conversions to or from floating-point values with the `BFloat16KHR` encoding first convert the source value to IEEE754 binary32, and then from IEEE754 binary32 to the target format. When converting from `BFloat16KHR` to IEEE754 binary32, the additional significand bits are padded with 0s, producing the exact same value. When converting from IEEE754 binary32 to `BFloat16KHR`, the rounding mode is defined by the client API.
Arithmetic Instructions
Add the following requirement to OpDot:
If the Result Type (and the component types of Vector 1 and Vector 2) has a *BFloat16KHR* encoding then *BFloat16DotProductKHR* must be declared.
Capabilities
Modify Section 3.31, Capability, adding this row to the Capability table:
| Capability | Implicitly Declares | |
|---|---|---|
5116 |
BFloat16TypeKHR |
|
5117 |
BFloat16DotProductKHR |
BFloat16TypeKHR |
5118 |
BFloat16CooperativeMatrixKHR |
BFloat16TypeKHR, CooperativeMatrixKHR |
Validation Rules
Add the following bullets to section 2.16.1, Universal Validation Rules:
-
Objects with a type that is or includes a floating-point type with the BFloat16KHR encoding must only be used with the following instructions:
-
OpDot
-
OpCooperativeMatrixMulAddKHR
-
OpCooperativeMatrixLengthKHR
-
OpSelect
-
OpPhi
-
OpReturnValue
-
OpLifetimeStart
-
OpLifetimeStop