Page MenuHomePhabricator

[mlir][Python] Fix generation of accessors for Optional
ClosedPublic

Authored by michalt on Nov 14 2021, 11:05 AM.

Details

Summary

Previously, in case there was only one Optional operand/result within
the list, we would always return None from the accessor, e.g., for a
single optional result we would generate:

return self.operation.results[0] if len(self.operation.results) > 1 else None

But what we really want is to return None only if the length of
results is smaller than the total number of element groups (i.e.,
the optional operand/result is in fact missing).

This commit also renames a few local variables in the generator to make
the distinction between isVariadic() and isVariableLength() a bit
more clear.

Diff Detail

Event Timeline

michalt created this revision.Nov 14 2021, 11:05 AM
michalt published this revision for review.Nov 14 2021, 11:08 AM

This is the first time I'm trying to do anything non-trivial with MLIR, so any feedback is very welcome (especially if I misunderstood/missed something :) Thanks!

Herald added a project: Restricted Project. · View Herald TranscriptNov 14 2021, 11:08 AM
ftynse accepted this revision.Nov 16 2021, 1:20 AM

Thanks for the fix! Please let me know if you need help landing this.

mlir/test/python/dialects/python_test.py
132

Nit: spurious whitespace change (this file uses two newlines between functions AFAICS).

This revision is now accepted and ready to land.Nov 16 2021, 1:20 AM
michalt updated this revision to Diff 387829.Nov 16 2021, 10:01 PM
michalt marked an inline comment as done.

Fix whitespace

Thanks for the fix! Please let me know if you need help landing this.

Thank you for a quick review! :) I don't have commit access, so it'd be great if you could land this, thanks!

Something went wrong and now the diff contains only the whitespace changes. If you made them as two separate git commits, please indicate the two-commit range when updating the revision or squash them.

michalt updated this revision to Diff 388109.Nov 17 2021, 10:06 PM

Correctly export the whatespace fix to Phab

Something went wrong and now the diff contains only the whitespace changes. If you made them as two separate git commits, please indicate the two-commit range when updating the revision or squash them.

Yikes! I haven't used arc for a couple of years... and indeed I made a separate commit and didn't specify the range correctly when running arc diff. Sorry for that!

This revision was automatically updated to reflect the committed changes.