This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Fix confusing diagnostic during dialect conversion
ClosedPublic

Authored by bondhugula on Dec 22 2021, 2:48 AM.

Details

Summary

Fix confusing diagnostic during partial dialect conversion. A failure to
legalize is not the same as an operation being illegal: for eg. an
operation neither explicity marked legal nor explicitly marked illegal
could have been generated and may have failed to legalize further. The
op isn't an illegal one per
https://mlir.llvm.org/docs/DialectConversion/#conversion-target
which is an op that is explicitly marked illegal.

Diff Detail

Event Timeline

bondhugula created this revision.Dec 22 2021, 2:48 AM
bondhugula requested review of this revision.Dec 22 2021, 2:48 AM

The op isn't an illegal one per https://mlir.llvm.org/docs/DialectConversion/#conversion-target which is an op that is explicitly marked illegal.

Can you clarify this? I looked at the doc and your point isn't clear to me.
For example, to me if an op isn't illegal we should not even try to convert it at all.

I guess something in the doc isn't clear to me: it does not define anything else than legal or illegal as far as I can tell. To me that has been enough to reason about the process, but you're introducing here another state where an operation is neither legal nor illegal?
This third state kind of exists for the purpose of failing the partial legalization I guess, but I can't figure out where it'd be really defined in the section you're linking to?

The op isn't an illegal one per https://mlir.llvm.org/docs/DialectConversion/#conversion-target which is an op that is explicitly marked illegal.

Can you clarify this? I looked at the doc and your point isn't clear to me.
For example, to me if an op isn't illegal we should not even try to convert it at all.

Well, we have a tri-state: explicitly marked legal, explicitly marked illegal, and those that are neither of the former two. The three are treated differently -- for example with a partial conversion, you can end up with success with ops of the last kind but not with those of the second kind.

Right, I mentioned this in my last message.

Seems like the doc should get updated to reflect this if we want to embrace the "tri-state": right now I see these ops as illegal, they don't make a partial conversion fail.

mehdi_amini accepted this revision.Dec 22 2021, 1:41 PM

I'm fine with changing the debug output though.

This revision is now accepted and ready to land.Dec 22 2021, 1:41 PM

Right, I mentioned this in my last message.

Seems like the doc should get updated to reflect this if we want to embrace the "tri-state": right now I see these ops as illegal, they don't make a partial conversion fail.

That's right. The doc needs an update here - it can get quite tricky and confusing the way it's now. I'm happy to tackle that in this revision too. I'll update and will need a review for that.

Update dialect conversion doc.

Tweak doc update.

mehdi_amini added 1 blocking reviewer(s): rriddle.Dec 28 2021, 12:51 AM
This revision now requires review to proceed.Dec 28 2021, 12:51 AM
rriddle accepted this revision.Jan 1 2022, 3:15 PM

LG, thanks.

mlir/lib/Transforms/Utils/DialectConversion.cpp
1934

nit: failed to legalized <blah>

Feels like ^ would read better, unless what you have matches other messages

This revision is now accepted and ready to land.Jan 1 2022, 3:15 PM
bondhugula updated this revision to Diff 396910.Jan 1 2022, 9:29 PM
bondhugula marked an inline comment as done.

Improve diagnostic.

bondhugula updated this revision to Diff 396911.Jan 1 2022, 9:30 PM

Adjust other failure messages to be consistent.

mlir/lib/Transforms/Utils/DialectConversion.cpp
1934

Sure, done.