This is an archive of the discontinued LLVM Phabricator instance.

[mlir][transform][python] Add extended ApplyPatternsOp.
ClosedPublic

Authored by ingomueller-net on Jul 17 2023, 3:29 AM.

Details

Summary

This patch adds a mixin for ApplyPatternsOp to _transform_ops_ext.py
with syntactic sugar for construction such ops. Curiously, the op did
not have any constructors yet, probably because its tablegen definition
said to skip the default builders. The new constructor is thus quite
straightforward. The commit also adds a refined region property which
returns the first block of the single region.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 3:29 AM

Adding tests and rephrasing commit message.

ingomueller-net published this revision for review.Jul 18 2023, 4:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 4:00 AM

Nit: can we retitle the commit to explicitly refer to python bindings? Currently it reads as if it were actually adding an op.

mlir/python/mlir/dialects/_transform_ops_ext.py
54

It is confusing that region property returns a block rather than a region. Can we give it a different name?

Address @ftynse's comment:

  • Change commit title.
mlir/python/mlir/dialects/_transform_ops_ext.py
54

Ha, I had overlooked this comment until now.

Yes, I agree. Relatedly, the name region in the td file isn't particularly meaningful. Maybe that should be changed? Maybe body or patterns? (Then the name of this property would be the same.)

ftynse added inline comments.Jul 19 2023, 7:44 AM
mlir/python/mlir/dialects/_transform_ops_ext.py
54

Can we make it consistent with what's in ODS?

mlir/python/mlir/dialects/_transform_ops_ext.py
54

That's the current state: it is called "region" in ODS. If we want a different name *and* consistency, we need to change ODS.

mlir/python/mlir/dialects/_transform_ops_ext.py
54

In case it isn't clear: I can't address both of your requests at the same time, @ftynse, rename region and make it consistent with ODS, because it is called region in ODS. My preferred solution is to rename the region to patterns in ODS and do the same here. Does that work for you?

ftynse added inline comments.Jul 20 2023, 3:07 AM
mlir/python/mlir/dialects/_transform_ops_ext.py
54

Works for me, thanks!

ftynse accepted this revision.Jul 20 2023, 3:40 AM
This revision is now accepted and ready to land.Jul 20 2023, 3:40 AM