[Mlir-commits] [mlir] b33354f - [MLIR][Python][Transform] Print diagnostics also upon success (#172188)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Dec 13 16:35:56 PST 2025


Author: Rolf Morel
Date: 2025-12-14T00:35:52Z
New Revision: b33354f2723677740a2b3fc3de66b53855bdf969

URL: https://github.com/llvm/llvm-project/commit/b33354f2723677740a2b3fc3de66b53855bdf969
DIFF: https://github.com/llvm/llvm-project/commit/b33354f2723677740a2b3fc3de66b53855bdf969.diff

LOG: [MLIR][Python][Transform] Print diagnostics also upon success (#172188)

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

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/TransformInterpreter.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/TransformInterpreter.cpp b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
index 81c02e905505a..9e1eb37a816f6 100644
--- a/mlir/lib/Bindings/Python/TransformInterpreter.cpp
+++ b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
@@ -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 " +


        


More information about the Mlir-commits mailing list