In this file, some match and rewrite patterns has been defined for math operations. At the end of this file, all those rewrite patterns are added to the RewritePatternSet.
When and how are these transformations applied. Are they applied automatically or do I have to specify some options for mlir-opt tool to apply these transformations?
Nothing happens “automatically”, there is always the automation code somewhere. mlir-opt runs passes not patterns, so you need to find a pass that calls this function. Here it is llvm-project/TestPolynomialApproximation.cpp at main · llvm/llvm-project · GitHub. It’s a test pass, so I suppose some downstreams are mixing these patterns with other patterns in their own passes.
Thanks for the reply.
I was actually trying to write my own pass by following code written for the Math dialect. I have written and registered a pass (that performs a pattern match and rewrite transformation) as follows:
Here, mytoy is the namespace of the dialect MyToy that I have registered with the mlir (mlir-opt recognizes and parses the operations associated with this dialect). When I try to run this pass using the following command: