[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).
This commit is contained in:
Rolf Morel
2025-12-14 00:35:52 +00:00
committed by GitHub
parent 49ad1e9ea2
commit b33354f272

View File

@@ -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 " +