[Mlir-commits] [mlir] Save unregistered attrs after type conversion. (PR #135084)
Bart Chrzaszcz
llvmlistbot at llvm.org
Wed Apr 9 14:21:19 PDT 2025
https://github.com/bartchr808 created https://github.com/llvm/llvm-project/pull/135084
In [Shardy](https://github.com/openxla/shardy), we rely on unregistered attrs being preserved between conversion of different dialects. At one point, we convert between StableHLO and MHLO. When this occurs, we have a `CallOp` with type `stablehlo.token` that is converted to `mhlo.token`. When this occurs, we lose attributes due to this pattern not preserving them. This change makes sure they are preserved.
>From 01bf8807a041b411d2bd0c00ea6ca5ab06542805 Mon Sep 17 00:00:00 2001
From: Bart Chrzaszcz <bartchr at google.com>
Date: Wed, 9 Apr 2025 22:18:31 +0100
Subject: [PATCH] Save unregistered attrs after type conversion.
---
mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp b/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp
index a3638c8766a5c..2d15ed02fd87c 100644
--- a/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp
+++ b/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp
@@ -49,6 +49,7 @@ struct CallOpSignatureConversion : public OpConversionPattern<CallOp> {
auto newCallOp = rewriter.create<CallOp>(
callOp.getLoc(), callOp.getCallee(), convertedResults,
flattenValues(adaptor.getOperands()));
+ newCallOp->setAttrs(callOp->getAttrs());
SmallVector<ValueRange> replacements;
size_t offset = 0;
for (int i = 0, e = callOp->getNumResults(); i < e; ++i) {
More information about the Mlir-commits
mailing list