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

Andrey Pavlenko llvmlistbot at llvm.org
Wed Jan 7 12:08:29 PST 2026


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

>From 66308041b5e1f81792131b837e163b12a517bf84 Mon Sep 17 00:00:00 2001
From: Andrey Pavlenko <andrey.a.pavlenko at gmail.com>
Date: Fri, 19 Dec 2025 14:02:52 +0000
Subject: [PATCH] Fix VectorType clone with shape of a different rank

If the new shape has a different number of dims, VectorType::verify
fai with error: 'number of dims must match'.
---
 mlir/lib/IR/BuiltinTypes.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index ce47c60c9b932..5c40d2ac5bc0c 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());
+  ArrayRef<int64_t> shapeVal = shape.value_or(getShape());
+  SmallVector<bool> scalableDims(getScalableDims());
+  scalableDims.resize(shapeVal.size(), false);
+  return VectorType::get(shapeVal, elementType, scalableDims);
 }
 
 //===----------------------------------------------------------------------===//



More information about the Mlir-commits mailing list