This is an archive of the discontinued LLVM Phabricator instance.

[mlir] add structured (Linalg) transform op matchers
ClosedPublic

Authored by ftynse on Apr 11 2023, 7:19 AM.

Details

Summary

Add a set of transform operations into the "structured" extension of the
Transform dialect that allow one to select transformation targets more
specifically than the currently available matching. In particular, add
the mechanism for identifying the producers of operands (input and init
in destination-passing style) and users of results, as well as
mechanisms for reasoning about the shape of the iteration space.

Additionally, add several transform operations to manipulate parameters
that could be useful to implement more advanced selectors. Specifically,
new operations let one produce and compare parameter values to implement
shape-driven transformations.

New operations are placed in separate files to decrease compilation
time. Some relayering of the extension is necessary to avoid repeated
generation of enums.

Depends on D148013
Depends on D148014
Depends on D148015

Diff Detail

Event Timeline

ftynse created this revision.Apr 11 2023, 7:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:19 AM
ftynse updated this revision to Diff 512469.Apr 11 2023, 8:31 AM

Fix Bazel

ftynse published this revision for review.Apr 12 2023, 12:54 AM
chelini added inline comments.Apr 12 2023, 2:07 AM
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
92

What about more complex patterns like chain of binary ops?

110

I think this doc is repeated. StructuredPredicate will add it again.

mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
206

nit: drop is.

262

Why not using visited.count(updated)?

568

I wonder if we should adjust the matcher name with the names used in the DPS interface (i.e., MatchStructuredNumInitsOp)

mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
60

operations

60

it?

mlir/test/Dialect/Linalg/match-ops-invalid.mlir
106

I don't understand the error message. suggested: must request specific values in the list or 'all' if the list is not specified

170

I would go for: 'permutation' and 'projected permutation' are mutually exclusive

ftynse updated this revision to Diff 512755.Apr 12 2023, 3:49 AM
ftynse marked 9 inline comments as done.

Address review.

mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
92

The "single op" here refers to the fact that it considers one linalg op at a time, not to the body of said op. Added a more detailed comment on the trait.

mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
262

Because I would still need to insert afterwards. This does both and returns a pair of (iterator, was-actually-inserted).

568

Good question. I went with outputs because the Linalg syntax still uses outs, but maybe we should be forward-looking.

mlir/test/Dialect/Linalg/match-ops-invalid.mlir
106

Just a typo: must request s/of/if/ 'all' is not specified.

chelini accepted this revision.Apr 13 2023, 4:33 AM

Thank you. Looks good to me.

mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
262

Ok, got confused by line 265.

This revision is now accepted and ready to land.Apr 13 2023, 4:33 AM
This revision was landed with ongoing or failed builds.Apr 13 2023, 5:38 AM
This revision was automatically updated to reflect the committed changes.