[Mlir-commits] [mlir] [mlir] Fix VectorType clone with shape of a different rank (PR #173007)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Dec 19 06:10:02 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Andrey Pavlenko (AndreyPavlenko)

<details>
<summary>Changes</summary>

If the new shape has a different number of dims, VectorType::verify() fail with error: 'number of dims must match'.

---
Full diff: https://github.com/llvm/llvm-project/pull/173007.diff


1 Files Affected:

- (modified) mlir/lib/IR/BuiltinTypes.cpp (+4-2) 


``````````diff
diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index ce47c60c9b932..280ab437c1bd5 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -285,8 +285,10 @@ VectorType VectorType::scaleElementBitwidth(unsigned scale) {
 
 VectorType VectorType::cloneWith(std::optional<ArrayRef<int64_t>> shape,
                                  Type elementType) const {
-  return VectorType::get(shape.value_or(getShape()), elementType,
-                         getScalableDims());
+  auto shapeVal = shape.value_or(getShape());
+  SmallVector<bool> scalableDims(getScalableDims());
+  scalableDims.resize(shapeVal.size(), false);
+  return VectorType::get(shapeVal, elementType, scalableDims);
 }
 
 //===----------------------------------------------------------------------===//

``````````

</details>


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


More information about the Mlir-commits mailing list