[Mlir-commits] [mlir] [mlir][spirv] Add bfloat16 support (PR #141458)

Darren Wihandi llvmlistbot at llvm.org
Sun May 25 23:47:39 PDT 2025


================
@@ -4163,8 +4192,9 @@ def SPIRV_Int32 : TypeAlias<I32, "Int32">;
 def SPIRV_Float32 : TypeAlias<F32, "Float32">;
 def SPIRV_Float : FloatOfWidths<[16, 32, 64]>;
 def SPIRV_Float16or32 : FloatOfWidths<[16, 32]>;
+def SPIRV_FloatOrBFloat16 : AnyTypeOf<[SPIRV_Float, BF16]>;
 def SPIRV_Vector : VectorOfLengthAndType<[2, 3, 4, 8, 16],
-                                       [SPIRV_Bool, SPIRV_Integer, SPIRV_Float]>;
+                                       [SPIRV_Bool, SPIRV_Integer, SPIRV_FloatOrBFloat16]>;
----------------
fairywreath wrote:

We can argue that bf16 should be part of `SPIRV_Float`. The problem here is that bf16 usage in SPIRV is very limited while `SPIRV_Float`(i.e regular floats) is used widely in the codebase for other ops(eg. texture sampling and regular arithmetic insts). I chose to leave `SPIRV_Float` to minimize the amount of changes(and to not introduce something like `SPIRV_ArithmeticFloat`). Please let me know if there is a cleaner solution to this.

https://github.com/llvm/llvm-project/pull/141458


More information about the Mlir-commits mailing list