[Mlir-commits] [mlir] [mlir][linalg] Add more precise memory effects to linalg op (PR #92079)
donald chen
llvmlistbot at llvm.org
Fri May 17 06:28:39 PDT 2024
================
@@ -289,6 +289,9 @@ def MapOp : LinalgStructuredBase_Op<"map", [
bool payloadUsesValueFromOperand(OpOperand * opOperand) {
if (isDpsInit(opOperand)) return false;
+ if (getOperation()->getRegion(0).empty()) {
+ return true;
+ }
----------------
cxy-1993 wrote:
> I don't quite get this. When the region is empty (is this even allowed?), the operand is considered used? But when it has a terminator not reading from the corresponding block argument, the operand is not considered used? Why? If we assume it is read anyway, it should be marked as such in both cases.
Thank you for your suggestion! For this issue, here is my understanding: When region is empty, it usually occurs in scenarios where region does not need to interpret the semantics of op, such as linalg.map:
```
%mapped = linalg.map { arith.addf }
ins(%arg0, %arg1 : tensor<10x100xf32>, tensor<10x100xf32>)
outs(%map_init : tensor<10x100xf32>)
```
In the example above, the linalg.map has an empty region. This is because, with arith.add present, we do not need to provide additional interpretation for this op, as its implementation simply involves adding the two input operands. In such scenarios where no interpretation is required, we consider all operands to be used in accordance with the semantics of the op.
In linalg operations implemented with regions, it is evident that when the block arguments corresponding to operands are not used, it indicates that they are not being read.
https://github.com/llvm/llvm-project/pull/92079
More information about the Mlir-commits
mailing list