[Mlir-commits] [mlir] [mlir][vector] Fix invalid IR in `ContractionOpLowering` (PR #78130)

Matthias Springer llvmlistbot at llvm.org
Tue Jan 16 00:19:49 PST 2024


================
@@ -458,49 +450,70 @@ struct UnrolledOuterProductGenerator
     return res;
   }
 
+  std::optional<int64_t> getReductionSize(VectorType vecType,
+                                          int64_t reductionDim) {
+    // Cannot unroll scalable dimension.
+    if (vecType.getScalableDims()[reductionDim])
+      return std::nullopt;
+    int64_t reductionSize = vecType.getDimSize(reductionDim);
+    assert(reductionSize > 0 &&
+           "Reduction dim must be a known static size to allow unrolling");
+    return reductionSize;
+  }
+
   /// Two outer parallel, one inner reduction (matmat flavor).
   FailureOr<Value> matmat() {
     if (!iters({Par(), Par(), Red()}))
       return failure();
     // Set up the parallel/reduction structure in the right form.
     AffineExpr m, n, k;
     bindDims(rewriter.getContext(), m, n, k);
-    Value transposedMask = t(mask, {2, 0, 1});
+
----------------
matthias-springer wrote:

We can keep it, but it must be nested inside the `if (auto reductionSize = getReductionSize(...))` check. (Because the implementation creates IR and the `if` checks will determine if the pattern succeeds or fails.)


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


More information about the Mlir-commits mailing list