[Mlir-commits] [mlir] [mlir][vector] Handle rank mismatch when unrolling broadcasts (PR #227351)
purnima shrivastava
llvmlistbot at llvm.org
Sat Oct 3 10:22:26 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());
----------------
purnima-nlp wrote:
Done, updated this to use `llvm::copy` and match the existing implementation.
https://github.com/llvm/llvm-project/pull/227351
More information about the Mlir-commits
mailing list