Skip to content

Conversation

@ddubov100
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2025

@llvm/pr-subscribers-mlir-bufferization

@llvm/pr-subscribers-mlir-scf

Author: None (ddubov100)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/165381.diff

2 Files Affected:

  • (modified) mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp (+1)
  • (modified) mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir (+3-2)
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

@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2025

@llvm/pr-subscribers-mlir

Author: None (ddubov100)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/165381.diff

2 Files Affected:

  • (modified) mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp (+1)
  • (modified) mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir (+3-2)
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());
Copy link
Member

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.

Copy link
Collaborator

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())

Copy link
Contributor Author

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?

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:bufferization Bufferization infrastructure mlir:scf mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants