This is an archive of the discontinued LLVM Phabricator instance.

[mlir][python] Support more types in IntegerAttr.value
ClosedPublic

Authored by rkayaith on Feb 19 2022, 1:59 PM.

Details

Summary

Previously only accessing values for index and signless int types
would work; signed and unsigned ints would hit an assert in
IntegerAttr::getInt. This exposes IntegerAttr::get{S,U}Int to the C
API and calls the appropriate function from the python bindings.

Diff Detail

Event Timeline

rkayaith created this revision.Feb 19 2022, 1:59 PM
rkayaith published this revision for review.Feb 19 2022, 2:59 PM
ftynse accepted this revision.Feb 21 2022, 12:50 AM
ftynse added inline comments.
mlir/lib/Bindings/Python/IRAttributes.cpp
262

Is the type ever not an integer? This check feels more like assertion, especially given that the code inside the conditional does nothing for signless integers.

This revision is now accepted and ready to land.Feb 21 2022, 12:50 AM
rkayaith updated this revision to Diff 410324.Feb 21 2022, 9:11 AM

add explicit index type check and test for index intattr

rkayaith added inline comments.Feb 21 2022, 9:14 AM
mlir/lib/Bindings/Python/IRAttributes.cpp
262

Yes, the index type would fail the "is integer" check and fall through to the signless case. I've updated the logic here to make the handling of index clearer.

Thanks for the review, could you land this if it looks good?

This revision was automatically updated to reflect the committed changes.