Hot off the presses: ⚙ D157934 [mlir][python bindings] generate all the enums
A couple or three things about this diff/PR/changeset:
- Upstream dialects now have automatic bindings generated for
*EnumAttrs (includingI32EnumAttrs,I32BitEnumAttrs, and plainEnumAttrs, i.e., dialect enum attributes). See here, here, and here for examples. - If you were already using
register_attribute_builderto register an attribute builder for some such enum and you would like to continue to use it, you can by passingreplace=Trueto the decorator (see here). Note that you need to do this after the upstream one is registered (i.e., after the dialect module is imported); otherwise you will get aRuntimeErrorabout duplicate registration (when the upstream attribute builder tries to replace yours). - Downstream dialects can sign up for the same automatic generation using the
GEN_ENUM_BINDINGSparam todeclare_mlir_dialect_python_bindings(see here). Note this will generate bindings for allEnumAttrs defined in your trampoline*Ops.tdincluding definitions in imports/includes. If your*Ops.tdhas upstream dialecttds included then you might end up generating duplicated bindings and if so they will collide with existing bindings (same aforementionedRuntimeError). Currently the workaround is to either refactor your*Ops.tdor use the soon-to-be-deprecatedGEN_ENUM_BINDINGS_TD_FILEparam (see this discussion on the phabricator review).
Thanks @rkayaith and @stellaraccident for the review.
Any questions/comments/concerns can be directed directly at me.
Thank you for flying with us and we hope you have a nice day.