[Mlir-commits] [mlir] [MLIR][Python][Transform] Print diagnostics also upon success (PR #172188)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Dec 13 16:16:59 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Rolf Morel (rolfmorel)
<details>
<summary>Changes</summary>
If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied successfully, the Scope object's destructor will assert (with a unhelpful message).
---
Full diff: https://github.com/llvm/llvm-project/pull/172188.diff
1 Files Affected:
- (modified) mlir/lib/Bindings/Python/TransformInterpreter.cpp (+11-2)
``````````diff
diff --git a/mlir/lib/Bindings/Python/TransformInterpreter.cpp b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
index 920bca886f617..9e1eb37a816f6 100644
--- a/mlir/lib/Bindings/Python/TransformInterpreter.cpp
+++ b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
@@ -14,8 +14,8 @@
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"
#include "mlir/Bindings/Python/Diagnostics.h"
-#include "mlir/Bindings/Python/NanobindAdaptors.h"
#include "mlir/Bindings/Python/Nanobind.h"
+#include "mlir/Bindings/Python/NanobindAdaptors.h"
namespace nb = nanobind;
@@ -70,8 +70,17 @@ static void populateTransformInterpreterSubmodule(nb::module_ &m) {
MlirLogicalResult result = mlirTransformApplyNamedSequence(
payloadRoot, transformRoot, transformModule, options.options);
- if (mlirLogicalResultIsSuccess(result))
+ if (mlirLogicalResultIsSuccess(result)) {
+ // Even in cases of success, we might have diagnostics to report:
+ std::string msg;
+ if ((msg = scope.takeMessage()).size() > 0) {
+ fprintf(stderr,
+ "Diagnostic generated while applying "
+ "transform.named_sequence:\n%s",
+ msg.data());
+ }
return;
+ }
throw nb::value_error(
("Failed to apply named transform sequence.\nDiagnostic message " +
``````````
</details>
https://github.com/llvm/llvm-project/pull/172188
More information about the Mlir-commits
mailing list