Skip to content

Commit e1417e0

Browse files
committed
[mlir] [linalg] fix side effect of linalg op
Linalg op need to take into account memory side effects happening inside the region when determining their own side effects. This patch fixed issue #112881
1 parent 98c8d64 commit e1417e0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class LinalgStructuredBase_Op<string mnemonic, list<Trait> props>
3030
SingleBlockImplicitTerminator<"YieldOp">,
3131
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
3232
DeclareOpInterfaceMethods<ConditionallySpeculatable>,
33+
RecursiveMemoryEffects,
3334
DestinationStyleOpInterface,
3435
LinalgStructuredInterface,
3536
ReifyRankedShapedTypeOpInterface], props)> {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: mlir-opt %s --canonicalize | FileCheck %s
2+
3+
func.func @map(%arg0: memref<1xf32>, %arg1 : tensor<1xf32>) {
4+
%c1 = arith.constant 1 : index
5+
%init = arith.constant dense<0.0> : tensor<1xf32>
6+
%mapped = linalg.map ins(%arg1:tensor<1xf32>) outs(%init :tensor<1xf32>)
7+
(%in : f32) {
8+
memref.store %in, %arg0[%c1] : memref<1xf32>
9+
linalg.yield %in : f32
10+
}
11+
func.return
12+
}
13+
14+
// CHECK-LABEL: @map
15+
// CHECK: linalg.map

0 commit comments

Comments
 (0)