-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Keep attributes on bufferization of execute_region. #165381
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
base: main
Are you sure you want to change the base?
Keep attributes on bufferization of execute_region. #165381
Conversation
|
@llvm/pr-subscribers-mlir-bufferization @llvm/pr-subscribers-mlir-scf Author: None (ddubov100) ChangesFull diff: https://github.com/llvm/llvm-project/pull/165381.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
index 47c99642b9c37..c4b23b5d8c0c6 100644
--- a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -190,6 +190,7 @@ struct ExecuteRegionOpInterface
// Create new op and move over region.
auto newOp = scf::ExecuteRegionOp::create(
rewriter, op->getLoc(), newResultTypes, executeRegionOp.getNoInline());
+ newOp->setAttrs(executeRegionOp->getAttrs());
newOp.getRegion().takeBody(executeRegionOp.getRegion());
// Bufferize every block.
diff --git a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
index 8db1ebb87a1e5..fa4f6dfa9de40 100644
--- a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
+++ b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
@@ -369,10 +369,11 @@ func.func private @execute_region_test(%t1 : tensor<?xf32>)
// CHECK-NOT: alloc
// CHECK-NOT: copy
// CHECK: memref.store %{{.*}}, %[[m1]][%{{.*}}]
- %0, %1, %2 = scf.execute_region -> (f32, tensor<?xf32>, f32) {
+ %0, %1, %2 = scf.execute_region -> (f32, tensor<?xf32>, f32) no_inline {
%t2 = tensor.insert %f2 into %t1[%idx] : tensor<?xf32>
scf.yield %f1, %t2, %f2 : f32, tensor<?xf32>, f32
- }
+ // CHECK: {test.custom_attr = "custom_value"}
+ } {test.custom_attr = "custom_value"}
// CHECK: return %{{.*}}, %{{.*}} : f32, f32
return %0, %1, %2 : f32, tensor<?xf32>, f32
|
|
@llvm/pr-subscribers-mlir Author: None (ddubov100) ChangesFull diff: https://github.com/llvm/llvm-project/pull/165381.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
index 47c99642b9c37..c4b23b5d8c0c6 100644
--- a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -190,6 +190,7 @@ struct ExecuteRegionOpInterface
// Create new op and move over region.
auto newOp = scf::ExecuteRegionOp::create(
rewriter, op->getLoc(), newResultTypes, executeRegionOp.getNoInline());
+ newOp->setAttrs(executeRegionOp->getAttrs());
newOp.getRegion().takeBody(executeRegionOp.getRegion());
// Bufferize every block.
diff --git a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
index 8db1ebb87a1e5..fa4f6dfa9de40 100644
--- a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
+++ b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
@@ -369,10 +369,11 @@ func.func private @execute_region_test(%t1 : tensor<?xf32>)
// CHECK-NOT: alloc
// CHECK-NOT: copy
// CHECK: memref.store %{{.*}}, %[[m1]][%{{.*}}]
- %0, %1, %2 = scf.execute_region -> (f32, tensor<?xf32>, f32) {
+ %0, %1, %2 = scf.execute_region -> (f32, tensor<?xf32>, f32) no_inline {
%t2 = tensor.insert %f2 into %t1[%idx] : tensor<?xf32>
scf.yield %f1, %t2, %f2 : f32, tensor<?xf32>, f32
- }
+ // CHECK: {test.custom_attr = "custom_value"}
+ } {test.custom_attr = "custom_value"}
// CHECK: return %{{.*}}, %{{.*}} : f32, f32
return %0, %1, %2 : f32, tensor<?xf32>, f32
|
| // Create new op and move over region. | ||
| auto newOp = scf::ExecuteRegionOp::create( | ||
| rewriter, op->getLoc(), newResultTypes, executeRegionOp.getNoInline()); | ||
| newOp->setAttrs(executeRegionOp->getAttrs()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this? Forwarding discardable attributes is controversial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the API should be setDiscardableAttrs(getDiscardableAttrs())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the agreed process of forwarding discardable attributes in case in my project I need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently no consensus on forwarding discardable attributes and projects are working around this issue downstream.
No description provided.