[Mlir-commits] [mlir] [mlir][x86vector] Lower BF16 vector.contract to FMA using AVX2 BF16 packed ops. (PR #170267)

Adam Siemieniuk llvmlistbot at llvm.org
Wed Dec 17 04:33:39 PST 2025


================
@@ -26,28 +26,39 @@ using namespace mlir;
 using namespace mlir::vector;
 using namespace mlir::x86vector;
 
-static bool validateVectorProdOp(Value prodOp) {
+// Verifies that the LHS and RHS operands of a vector.contract are load or
+// vector.transfer_read operations on a memref source buffer, and checks
+// their bounds, dimensions, offsets, and strides.
+static bool validateVectorContractOperands(Value prodOp) {
   Operation *defOp = prodOp.getDefiningOp();
   if (!defOp)
     return false;
 
-  // If the LHS/RHS op is transfer_read return false if:
-  // (1) - It has false in-bounds
-  // (2) - The permutation map is not identical
+  // Verify that the transfer_read operation satisfies the following conditions:
+  // (1) It has no out-of-bounds dimensions.
+  // (2) The permutation map is non-identity.
   if (auto readOp = prodOp.getDefiningOp<mlir::vector::TransferReadOp>()) {
-    ArrayAttr inBoundsAttr = readOp.getInBoundsAttr();
-    if (inBoundsAttr) {
-
-      for (Attribute attr : inBoundsAttr) {
-        auto boolAttr = llvm::dyn_cast<BoolAttr>(attr);
-        if (!boolAttr || !boolAttr.getValue()) {
-          return false;
-        }
-      }
-    }
+    if (readOp.hasOutOfBoundsDim())
+      return false;
+
+    AffineMap map = readOp.getPermutationMap();
 
-    if (!readOp.getPermutationMap().isIdentity())
+    // Must be a projected permutation (no skewing, no sums).
+    if (!map.isProjectedPermutation())
----------------
adam-smnk wrote:

Ahh sorry, I see there's more validation below.
Wouldn't `isMinorIdentity()` API suffice?

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


More information about the Mlir-commits mailing list