|
| 1 | +# Standalone Transform Dialect Interpreter |
| 2 | + |
| 3 | +This is an example of using the Transform dialect interpreter functionality standalone, that is, outside of the regular pass pipeline. The example is a |
| 4 | +binary capable of processing MLIR source files similar to `mlir-opt` and other |
| 5 | +optimizer drivers, with the entire transformation process driven by a Transform |
| 6 | +dialect script. This script can be embedded into the source file or provided in |
| 7 | +a separate MLIR source file. |
| 8 | + |
| 9 | +Either the input module or the transform module must contain a top-level symbol |
| 10 | +named `__transform_main`, which is used as the entry point to the transformation |
| 11 | +script. |
| 12 | + |
| 13 | +```sh |
| 14 | +mlir-transform-opt payload_with_embedded_transform.mlir |
| 15 | +mlir-transform-opt payload.mlir -transform=transform.mlir |
| 16 | +``` |
| 17 | + |
| 18 | +The name of the entry point can be overridden using command-line options. |
| 19 | + |
| 20 | +```sh |
| 21 | +mlir-transform-opt payload-mlir -transform-entry-point=another_entry_point |
| 22 | +``` |
| 23 | + |
| 24 | +Transform scripts can reference symbols defined in other source files, called |
| 25 | +libraries, which can be supplied to the binary through command-line options. |
| 26 | +Libraries will be embedded into the main transformation module by the tool and |
| 27 | +the interpreter will process everything as a single module. A debug option is |
| 28 | +available to see the contents of the transform module before it goes into the interpreter. |
| 29 | + |
| 30 | +```sh |
| 31 | +mlir-transform-opt payload.mlir -transform=transform.mlir \ |
| 32 | + -transform-library=external_definitions_1.mlir \ |
| 33 | + -transform-library=external_definitions_2.mlir \ |
| 34 | + -dump-library-module |
| 35 | +``` |
| 36 | + |
| 37 | +Check out the [Transform dialect |
| 38 | +tutorial](https://mlir.llvm.org/docs/Tutorials/transform/) as well as |
| 39 | +[documentation](https://mlir.llvm.org/docs/Dialects/Transform/) to learn more |
| 40 | +about the dialect. |
0 commit comments