This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][python bindings] Add some AttrBuilder and port _exts to use them.
ClosedPublic

Authored by makslevental on Apr 26 2023, 1:27 PM.

Details

Summary

_pdl_ops_ext, _structured_transform_ops_ext, _loop_transform_ops_ext, and _transform_ops_ext have some useful factory functions for attributes. This diff migrates them to use the register_attribute_builder mechanism, which simultaneously has the effect of cleaning up the existing code and making them available for downstream users of the python bindings.

I also ran black | yapf on the scripts to make them more readable.

Diff Detail

Event Timeline

makslevental created this revision.Apr 26 2023, 1:27 PM
Herald added a project: Restricted Project. · View Herald Transcript
makslevental edited the summary of this revision. (Show Details)Apr 26 2023, 1:31 PM
makslevental updated this revision to Diff 517302.EditedApr 26 2023, 1:41 PM

put type hints back and include _loop_transform_ops

makslevental edited the summary of this revision. (Show Details)Apr 26 2023, 1:42 PM

remove commented code

remove no-op assignments

makslevental published this revision for review.Apr 26 2023, 1:50 PM
makslevental added inline comments.
mlir/python/mlir/dialects/_pdl_ops_ext.py
29–30

the "correct" way to do mutable args in python

ftynse accepted this revision.Apr 26 2023, 2:08 PM
This revision is now accepted and ready to land.Apr 26 2023, 2:08 PM
shabalin accepted this revision.Apr 26 2023, 2:40 PM