[Mlir-commits] [mlir] [mlir][tosa] Support more float types in resource transpose folding (PR #213226)

Thibaut Goetghebuer-Planchon llvmlistbot at llvm.org
Tue Aug 4 02:44:59 PDT 2026


================
@@ -231,6 +254,19 @@ DenseElementsAttr transpose(ElementsAttr attr, ShapedType inputType,
     if (auto data = tryGetDenseResourceValues<float>(attr);
         data && elementTy.isF32())
       return transposeType(*data, inputType, outputType, permValues);
+
+    if (auto data = tryGetDenseResourceValues<uint8_t>(attr);
+        data && isa<Float4E2M1FNType, Float8E4M3FNType, Float8E5M2Type,
+                    Float8E8M0FNUType>(elementTy))
+      return transposeRawType(*data, inputType, outputType, permValues);
----------------
Tessil wrote:

It should be safe as [isValidRawBuffer](https://github.com/llvm/llvm-project/blob/586e6593ebb55c2c2e9244c16ba5fee6c14198e5/mlir/lib/IR/BuiltinAttributes.cpp#L969) will call [getDenseElementStorageWidth](https://github.com/llvm/llvm-project/blob/b4deecd89085c11225c428cbb27c2e44925e78d9/mlir/lib/IR/BuiltinAttributes.cpp#L458-L465) which checks for 8-bit alignment and size. FP4 DenseResource should use 8-bit for each element or it will be reject.

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


More information about the Mlir-commits mailing list