[Mlir-commits] [mlir] [mlir][vector] Handle rank mismatch when unrolling broadcasts (PR #227351)

Federico Bruzzone llvmlistbot at llvm.org
Wed Sep 30 04:56:55 PDT 2026


================
@@ -808,16 +808,23 @@ struct UnrollBroadcastPattern : public OpRewritePattern<vector::BroadcastOp> {
     Location loc = broadcastOp.getLoc();
     VectorType srcType = dyn_cast<VectorType>(broadcastOp.getSourceType());
     VectorType resType = broadcastOp.getResultVectorType();
+
+    SmallVector<int64_t> originalShape = *broadcastOp.getShapeForUnroll();
+    // Pad the target shape with leading unit dimensions when the broadcast
+    // result has a higher rank than the native shape.
+    SmallVector<int64_t> adjustedTargetShape(originalShape.size(), 1);
+    std::copy(targetShape->begin(), targetShape->end(),
+              adjustedTargetShape.end() - targetShape->size());
----------------
FedericoBruzzone wrote:

Why not replicate the following:
https://github.com/llvm/llvm-project/blob/bf32f67b03bacaef3b4071a8429371f45efa5a2e/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp#L388-L392



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


More information about the Mlir-commits mailing list