[Mlir-commits] [mlir] Save unregistered attrs after type conversion. (PR #135084)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 9 14:21:54 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Bart Chrzaszcz (bartchr808)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/135084.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp (+1)
``````````diff
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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/135084
More information about the Mlir-commits
mailing list