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
*EnumAttr
s (includingI32EnumAttr
s,I32BitEnumAttr
s, and plainEnumAttr
s, i.e., dialect enum attributes). See here, here, and here for examples. - If you were already using
register_attribute_builder
to register an attribute builder for some such enum and you would like to continue to use it, you can by passingreplace=True
to 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 aRuntimeError
about 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_BINDINGS
param todeclare_mlir_dialect_python_bindings
(see here). Note this will generate bindings for allEnumAttr
s defined in your trampoline*Ops.td
including definitions in imports/includes. If your*Ops.td
has upstream dialecttd
s 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.td
or use the soon-to-be-deprecatedGEN_ENUM_BINDINGS_TD_FILE
param (see this discussion on the phabricator review).
Thanks @troggo 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.