Skip to content

Commit b33354f

Browse files
authored
[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).
1 parent 49ad1e9 commit b33354f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mlir/lib/Bindings/Python/TransformInterpreter.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,17 @@ static void populateTransformInterpreterSubmodule(nb::module_ &m) {
7070

7171
MlirLogicalResult result = mlirTransformApplyNamedSequence(
7272
payloadRoot, transformRoot, transformModule, options.options);
73-
if (mlirLogicalResultIsSuccess(result))
73+
if (mlirLogicalResultIsSuccess(result)) {
74+
// Even in cases of success, we might have diagnostics to report:
75+
std::string msg;
76+
if ((msg = scope.takeMessage()).size() > 0) {
77+
fprintf(stderr,
78+
"Diagnostic generated while applying "
79+
"transform.named_sequence:\n%s",
80+
msg.data());
81+
}
7482
return;
83+
}
7584

7685
throw nb::value_error(
7786
("Failed to apply named transform sequence.\nDiagnostic message " +

0 commit comments

Comments
 (0)