[Mlir-commits] [mlir] Reland "[mlir][reducer] Add eraseRedundantBlocksInRegion and getSuccessorForwardOperands API to BranchOpInterface" (PR #189253)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 6 14:26:11 PDT 2026
google-yfyang wrote:
This change fails one tensorflow test https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tensorflow/tests/tf-reduce-identity.mlir:
with the following error message:
```
F0406 14:13:41.672739 10333 logging.cc:51] assert.h assertion failed at [llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:919] in LogicalResult mlir::applyPatternsGreedily(Region &, const FrozenRewritePatternSet &, GreedyRewriteConfig, bool *): region.getParentOp()->hasTrait<OpTrait::IsIsolatedFromAbove>() && "patterns can only be applied to operations IsolatedFromAbove"
*** Check failure stack trace: ***
@ 0x5564180a0aa9 absl::log_internal::LogMessage::SendToLog()
@ 0x5564180a0a2e absl::log_internal::LogMessage::Flush()
@ 0x5564180329f4 __assert_fail
@ 0x556415723eb1 mlir::applyPatternsGreedily()
@ 0x556414a23004 (anonymous namespace)::ReductionTreePass::runOnOperation()
@ 0x5564159782cc llvm::function_ref<>::callback_fn<>()
@ 0x55641597030d mlir::detail::OpToOpPassAdaptor::run()
@ 0x556415970e7e mlir::detail::OpToOpPassAdaptor::runPipeline()
@ 0x556415976926 mlir::PassManager::runPasses()
@ 0x556415976127 mlir::PassManager::run()
@ 0x556414a1f099 mlir::mlirReduceMain()::$_1::operator()()
@ 0x556414a1e410 mlir::mlirReduceMain()
@ 0x55640f440321 main
@ 0x7fa363f53f12 __libc_start_main
@ 0x55640f44002a _start
```
If I change
```
if (smallestNode == nullptr)
(void)applyPatternsGreedily(region.getParentOp(), fPatterns, config);
```
to
```
if (smallestNode == nullptr) {
Operation *isolatedParent = region.getParentOp();
if (!isolatedParent->hasTrait<OpTrait::IsIsolatedFromAbove>()) {
isolatedParent =
isolatedParent->getParentWithTrait<OpTrait::IsIsolatedFromAbove>();
}
if (isolatedParent) {
(void)applyPatternsGreedily(isolatedParent, fPatterns, config);
}
}
```
on line 294 in mlir/lib/Reducer/ReductionTreePass.cpp the test would pass. Does this solution look right to you?
https://github.com/llvm/llvm-project/pull/189253
More information about the Mlir-commits
mailing list