[Mlir-commits] [mlir] [MLIR] Add `InParallelOpInterface` for parallel combining operations (PR #157736)
Mehdi Amini
llvmlistbot at llvm.org
Tue Sep 9 12:43:14 PDT 2025
================
@@ -10,18 +10,47 @@
using namespace mlir;
+/// Include the definitions of the interface.
+#include "mlir/Interfaces/ParallelCombiningOpInterface.cpp.inc"
+
//===----------------------------------------------------------------------===//
-// ParallelCombiningOpInterface
+// InParallelOpInterface
//===----------------------------------------------------------------------===//
+// TODO: Catch-22 with interface methods used to verify means methods can't
+// assume the impl is valid.
+LogicalResult mlir::detail::verifyInParallelOpInterface(Operation *op) {
+ auto inParallel = cast<InParallelOpInterface>(op);
+ auto parent = inParallel.getIteratingParent();
+ if (!parent) {
+ return op->emitError(
+ "in_parallel interface op must have an iterating parent");
+ }
+
+ // Simple verification without requiring ParallelIterationOpInterface
+ // Just check that updated destinations are block arguments
+ for (OpOperand &updatedValue : inParallel.getUpdatedDestinations()) {
+ auto bbArg = dyn_cast<BlockArgument>(updatedValue.get());
+ if (!bbArg) {
+ return op->emitError("updating a non block argument");
+ }
+ }
+ return success();
+}
+
+
+//===----------------------------------------------------------------------===//
+// ParallelCombiningOpInterface
+//===----------------------------------------------------------------------===//
// TODO: Single region single block interface on interfaces ?
LogicalResult mlir::detail::verifyParallelCombiningOpInterface(Operation *op) {
if (op->getNumRegions() != 1)
return op->emitError("expected single region op");
if (!op->getRegion(0).hasOneBlock())
return op->emitError("expected single block op region");
+ for (Operation &child : *op->getRegion(0).getBlocks().begin()) {
----------------
joker-eph wrote:
Oh it's iterating the block, I just figured. I think this should be shorter:
```suggestion
for (Operation &child : *op->getRegion(0).front()) {
```
https://github.com/llvm/llvm-project/pull/157736
More information about the Mlir-commits
mailing list