From b33354f2723677740a2b3fc3de66b53855bdf969 Mon Sep 17 00:00:00 2001 From: Rolf Morel Date: Sun, 14 Dec 2025 00:35:52 +0000 Subject: [PATCH] [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). --- mlir/lib/Bindings/Python/TransformInterpreter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Bindings/Python/TransformInterpreter.cpp b/mlir/lib/Bindings/Python/TransformInterpreter.cpp index 81c02e905505..9e1eb37a816f 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 " +