[Mlir-commits] [mlir] [WIP][mlir] Make `DenseElementsAttr::reshape(...)` take a shape instead of a type (PR #149947)

Mengmeng Sun llvmlistbot at llvm.org
Mon Jul 21 20:58:26 PDT 2025


================
@@ -1241,8 +1241,10 @@ ArrayRef<StringRef> DenseElementsAttr::getRawStringData() const {
 /// Return a new DenseElementsAttr that has the same data as the current
 /// attribute, but has been reshaped to 'newType'. The new type must have the
 /// same total number of elements as well as element type.
-DenseElementsAttr DenseElementsAttr::reshape(ShapedType newType) {
+DenseElementsAttr DenseElementsAttr::reshape(ArrayRef<int64_t> newShape) {
+
   ShapedType curType = getType();
+  auto newType = curType.cloneWith(newShape, curType.getElementType());
----------------
MengmSun wrote:

I think if result type conversion is intended then  we should keep the element type of  converted result type and use for subsequent lowering. Clone with `newType.getElementType` instead of `curType.getElementType`.

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


More information about the Mlir-commits mailing list