[Mlir-commits] [mlir] [mlir][linalg] Support subtracting accumulation in partial reduction … (PR #214033)

Federico Bruzzone llvmlistbot at llvm.org
Fri Aug 7 03:23:38 PDT 2026


================
@@ -562,7 +584,12 @@ struct LinalgOpPartialReductionInterface
         return op->emitOpError("Failed to anaysis the reduction operation.");
 
       Operation *reductionOp = combinerOps[0];
-      std::optional<TypedAttr> identity = arith::getNeutralElement(reductionOp);
+      std::optional<TypedAttr> identity;
+      if (isSubtractingAccumulation(reductionOp,
----------------
FedericoBruzzone wrote:

We're evaluating `isSubtractingAccumulation` in two path independently.
IMHO, it is worth encapsulating the identity and the builder into a single entity to avoid future misalignments and regressions. Something like:
```cpp
struct AGoodName {
  TypedAttr identity;
  std::function<Value(OpBuilder &, ...)> merge;
};
```

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


More information about the Mlir-commits mailing list