[Mlir-commits] [mlir] [MLIR][Linalg] Fix crash in packMatmulGreedily on non-matmul ops (PR #218947)

Hugo Trachino llvmlistbot at llvm.org
Fri Sep 11 03:42:58 PDT 2026


================
@@ -806,7 +806,9 @@ linalg::packMatmulGreedily(RewriterBase &rewriter, LinalgOp linalgOp,
   // 1. Infer dims that are important for matmul.
   FailureOr<ContractionDimensions> maybeDimensions =
       inferContractionDims(linalgOp);
-  if (failed(maybeDimensions)) {
+  // The inferred m/n/k may be empty when the op is not actually matmul-like.
+  if (failed(maybeDimensions) || maybeDimensions->m.empty() ||
+      maybeDimensions->n.empty() || maybeDimensions->k.empty()) {
----------------
nujaa wrote:

if `inferContractionDims` goal is to figure out matmul dimensions, would it make more sense if `inferContractionDims` itself returned failure in this case as it is not a matmul rather than updating the handling ? Are there other usage which may be impacted by returning failure here ?

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


More information about the Mlir-commits mailing list