Hi , can we use the transform dialect c++ api in a custom conversion pass? For example, in a matchAndRewrite() function, create an mlir::transform::TileOp and apply tiling on linalg matmul, then retrieve the payload result of TileOp, and do some traditional rewrite stuff.
Technically, you can.
I don’t think you should though. This adds a lot of complexity to the compilation flow and I don’t see a good reason for it. If the transformation strategy is just tiling, just call the tiling function directly. If the transformation is more than that and requires composition supported by the transform dialect, it is likely better to invert the flow and have the matching part of the pattern be performed as a separate “transform” operation, removing the complexity of the pattern rewriter.
Thank you for your advice. Will transform dialect be the standard pass pipeline for mlir and replace the traditional passes?
At this point, transform dialect is mechanism to build passes, not replace them. Similar to, e.g., the pattern rewriter.
You could have transform ops that populate a pass manager instead of the
--pass-pipeline command-line option if desired, but still running the pass manager underneath.
I think it was also covered in the talk in January, in particular this slide: Open MLIR Meeting 1-26-2023: Controllable Transformations in MLIR with the `transforms` dialect - YouTube
where the complementarity of the two is shown.