Page MenuHomePhabricator

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

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



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.

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

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.