summaryrefslogtreecommitdiff
path: root/mlir/examples/transform
diff options
context:
space:
mode:
authorOleksandr "Alex" Zinenko <zinenko@google.com>2024-02-09 17:35:14 +0100
committerGitHub <noreply@github.com>2024-02-09 17:35:14 +0100
commitb33b91a21788d439f49d6db4e7224c20f740f1a7 (patch)
tree2966f4eb6635b1b94089a08466d2f5045ce6e8e4 /mlir/examples/transform
parent7291761669dd63624ccaab30887aca7e9c7d3273 (diff)
[mlir] update transform dialect tutorials (#81199)
Use the "main" transform-interpreter pass instead of the test pass. This, along with the previously introduced debug extension, now allow tutorials to no longer depend on test passes and extensions.
Diffstat (limited to 'mlir/examples/transform')
-rw-r--r--mlir/examples/transform/Ch2/transform-opt/transform-opt.cpp22
-rw-r--r--mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp26
-rw-r--r--mlir/examples/transform/Ch4/transform-opt/transform-opt.cpp12
3 files changed, 8 insertions, 52 deletions
diff --git a/mlir/examples/transform/Ch2/transform-opt/transform-opt.cpp b/mlir/examples/transform/Ch2/transform-opt/transform-opt.cpp
index 3a975313f93f..874ad78c7e83 100644
--- a/mlir/examples/transform/Ch2/transform-opt/transform-opt.cpp
+++ b/mlir/examples/transform/Ch2/transform-opt/transform-opt.cpp
@@ -12,6 +12,7 @@
#include "MyExtension.h"
+#include "mlir/Dialect/Transform/Transforms/Passes.h"
#include "mlir/IR/DialectRegistry.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/InitAllDialects.h"
@@ -20,14 +21,6 @@
#include "mlir/Transforms/Passes.h"
#include <cstdlib>
-// Forward declarations of test passes that used in this chapter for
-// illustrative purposes. Test passes are not directly exposed for use in
-// binaries other than mlir-opt, which is too big to serve as an example.
-namespace mlir::test {
-void registerTestTransformDialectEraseSchedulePass();
-void registerTestTransformDialectInterpreterPass();
-} // namespace mlir::test
-
namespace test {
void registerTestTransformDialectExtension(mlir::DialectRegistry &);
} // namespace test
@@ -39,22 +32,15 @@ int main(int argc, char **argv) {
mlir::registerAllExtensions(registry);
registerMyExtension(registry);
+ // Register transform interpreter pass.
+ mlir::transform::registerInterpreterPass();
+
// Register a handful of cleanup passes that we can run to make the output IR
// look nicer.
mlir::registerCanonicalizerPass();
mlir::registerCSEPass();
mlir::registerSymbolDCEPass();
- // Register the test passes.
-#ifdef MLIR_INCLUDE_TESTS
- mlir::test::registerTestTransformDialectEraseSchedulePass();
- mlir::test::registerTestTransformDialectInterpreterPass();
- test::registerTestTransformDialectExtension(registry);
-#else
- llvm::errs() << "warning: MLIR built without test passes, interpreter "
- "testing will not be available\n";
-#endif // MLIR_INCLUDE_TESTS
-
// Delegate to the MLIR utility for parsing and pass management.
return mlir::MlirOptMain(argc, argv, "transform-opt-ch2", registry)
.succeeded()
diff --git a/mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp b/mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp
index 3c348c663aba..c9150c64a716 100644
--- a/mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp
+++ b/mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp
@@ -12,6 +12,7 @@
#include "MyExtension.h"
+#include "mlir/Dialect/Transform/Transforms/Passes.h"
#include "mlir/IR/DialectRegistry.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/InitAllDialects.h"
@@ -20,18 +21,6 @@
#include "mlir/Transforms/Passes.h"
#include <cstdlib>
-// Forward declarations of test passes that used in this chapter for
-// illustrative purposes. Test passes are not directly exposed for use in
-// binaries other than mlir-opt, which is too big to serve as an example.
-namespace mlir::test {
-void registerTestTransformDialectEraseSchedulePass();
-void registerTestTransformDialectInterpreterPass();
-} // namespace mlir::test
-
-namespace test {
-void registerTestTransformDialectExtension(mlir::DialectRegistry &);
-} // namespace test
-
int main(int argc, char **argv) {
// Register all "core" dialects and our transform dialect extension.
mlir::DialectRegistry registry;
@@ -39,22 +28,15 @@ int main(int argc, char **argv) {
mlir::registerAllExtensions(registry);
registerMyExtension(registry);
+ // Register the interpreter pass.
+ mlir::transform::registerInterpreterPass();
+
// Register a handful of cleanup passes that we can run to make the output IR
// look nicer.
mlir::registerCanonicalizerPass();
mlir::registerCSEPass();
mlir::registerSymbolDCEPass();
- // Register the test passes.
-#ifdef MLIR_INCLUDE_TESTS
- mlir::test::registerTestTransformDialectEraseSchedulePass();
- mlir::test::registerTestTransformDialectInterpreterPass();
- test::registerTestTransformDialectExtension(registry);
-#else
- llvm::errs() << "warning: MLIR built without test passes, interpreter "
- "testing will not be available\n";
-#endif // MLIR_INCLUDE_TESTS
-
// Delegate to the MLIR utility for parsing and pass management.
return mlir::MlirOptMain(argc, argv, "transform-opt-ch3", registry)
.succeeded()
diff --git a/mlir/examples/transform/Ch4/transform-opt/transform-opt.cpp b/mlir/examples/transform/Ch4/transform-opt/transform-opt.cpp
index 10190664b51c..03c84bdbccb8 100644
--- a/mlir/examples/transform/Ch4/transform-opt/transform-opt.cpp
+++ b/mlir/examples/transform/Ch4/transform-opt/transform-opt.cpp
@@ -21,10 +21,6 @@
#include "mlir/Transforms/Passes.h"
#include <cstdlib>
-namespace test {
-void registerTestTransformDialectExtension(mlir::DialectRegistry &);
-} // namespace test
-
int main(int argc, char **argv) {
// Register all "core" dialects and our transform dialect extension.
mlir::DialectRegistry registry;
@@ -39,14 +35,6 @@ int main(int argc, char **argv) {
mlir::registerSymbolDCEPass();
mlir::transform::registerInterpreterPass();
- // Register the test passes.
-#ifdef MLIR_INCLUDE_TESTS
- test::registerTestTransformDialectExtension(registry);
-#else
- llvm::errs() << "warning: MLIR built without test extension, interpreter "
- "testing will not be available\n";
-#endif // MLIR_INCLUDE_TESTS
-
// Delegate to the MLIR utility for parsing and pass management.
return mlir::MlirOptMain(argc, argv, "transform-opt-ch4", registry)
.succeeded()