Skip to content

[mlir] [linalg] fix side effect of linalg op #114045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LinalgStructuredBase_Op<string mnemonic, list<Trait> props>
SingleBlockImplicitTerminator<"YieldOp">,
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
DeclareOpInterfaceMethods<ConditionallySpeculatable>,
RecursiveMemoryEffects,
DestinationStyleOpInterface,
LinalgStructuredInterface,
ReifyRankedShapedTypeOpInterface], props)> {
Expand Down
17 changes: 17 additions & 0 deletions mlir/test/Dialect/Linalg/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1232,3 +1232,20 @@ func.func @transpose_buffer(%input: memref<?xf32>,
// CHECK-SAME: %[[VAL_1:.*]]: memref<?xf32>) {
// CHECK: linalg.transpose ins(%[[VAL_0]] : memref<?xf32>)
// CHECK-SAME: outs(%[[VAL_1]] : memref<?xf32>) permutation = [0]

// -----

// This test checks linalg op has a recursive memory effect. Otherwise
// linalg.map without a user would be DCEd.
func.func @recursive_effect(%arg : tensor<1xf32>) {
%init = arith.constant dense<0.0> : tensor<1xf32>
%mapped = linalg.map ins(%arg:tensor<1xf32>) outs(%init :tensor<1xf32>)
(%in : f32) {
vector.print %in : f32
linalg.yield %in : f32
}
func.return
}

// CHECK-LABEL: @recursive_effect
// CHECK: linalg.map
Loading