[mlir] [mlir][linalg] Support subtracting accumulation in partial reduction … (PR #214033)
Andrzej Warzyński
llvmlistbot at llvm.org
Fri Aug 14 09:54:14 PDT 2026
banach-space wrote:
> I would honestly just copy-over the flags, create the issue, raise it, and tackle this once the discussion is settled, at least not implement it in the scope of this PR, to have a consistent state after this PR is merged. It hasn't bothered anyone till now, I doubt it will soon.
+1 Just sign-post that this is done for consistency with addition and that we should re-visit at a later time.
> The current tiling infrastructure currently just clones the operation, and the corresponding overflow flags with it. It does not really handle it.
You can verify using this example:
```mlir
func.func @generic_op_tensors(
%arg0 : tensor<?x?x?xi32>, %arg1 : tensor<?x?x?xi32>) -> tensor<?x?x?xi32> {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c2 = arith.constant 2 : index
%0 = tensor.dim %arg0, %c0 : tensor<?x?x?xi32>
%1 = tensor.dim %arg0, %c1 : tensor<?x?x?xi32>
%2 = tensor.dim %arg0, %c2 : tensor<?x?x?xi32>
%3 = tensor.empty(%0, %1, %2) : tensor<?x?x?xi32>
%4 = linalg.generic
{indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d1, d2)>,
affine_map<(d0, d1, d2) -> (d0, d2, d1)>,
affine_map<(d0, d1, d2) -> (d2, d1, d0)>],
iterator_types = ["parallel", "parallel", "parallel"]}
ins(%arg0, %arg1 : tensor<?x?x?xi32>, tensor<?x?x?xi32>)
outs(%3 : tensor<?x?x?xi32>) {
^bb0(%arg2 : i32, %arg3: i32, %arg4: i32):
%5 = arith.addi %arg2, %arg3 overflow<nsw> : i32
linalg.yield %5 : i32
} -> tensor<?x?x?xi32>
return %4 : tensor<?x?x?xi32>
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
%0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op
%1, %loops:3 = transform.structured.tile_using_for %0 tile_sizes [2, 3, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
transform.yield
}
}
```
```bash
$ mlir-opt --transform-interpreter file.mlir
```
https://github.com/llvm/llvm-project/pull/214033
More information about the Mlir-commits
mailing list