[mlir][Vector] Drop declarative transforms
authorNicolas Vasilache <ntv@google.com>
Tue, 28 Jul 2020 13:58:44 +0000 (09:58 -0400)
committerNicolas Vasilache <ntv@google.com>
Tue, 28 Jul 2020 17:11:16 +0000 (13:11 -0400)
For the purpose of vector transforms, the Tablegen-based infra is subsumed by simple C++ pattern application. Deprecate declarative transforms whose complexity does not pay for itself.

Differential Revision: https://reviews.llvm.org/D84753

mlir/include/mlir/Dialect/Vector/CMakeLists.txt
mlir/include/mlir/Dialect/Vector/VectorTransformPatterns.td [deleted file]
mlir/lib/Dialect/Vector/CMakeLists.txt
mlir/test/lib/CMakeLists.txt
mlir/test/lib/DeclarativeTransforms/CMakeLists.txt [deleted file]
mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td [deleted file]
mlir/test/lib/DeclarativeTransforms/lit.local.cfg [deleted file]
mlir/test/lib/Transforms/CMakeLists.txt
mlir/test/lib/Transforms/TestVectorTransforms.cpp

index a27eef6..23ad74e 100644 (file)
@@ -1,6 +1,2 @@
 add_mlir_dialect(VectorOps vector)
 add_mlir_doc(VectorOps -gen-op-doc VectorOps Dialects/)
-
-set(LLVM_TARGET_DEFINITIONS VectorTransformPatterns.td)
-mlir_tablegen(VectorTransformPatterns.h.inc -gen-rewriters)
-add_public_tablegen_target(MLIRVectorTransformPatternsIncGen)
diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransformPatterns.td b/mlir/include/mlir/Dialect/Vector/VectorTransformPatterns.td
deleted file mode 100644 (file)
index ef8118e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//===- VectorTransformPatterns.td - Vector-Vector patterns -*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This is the pattern definition file for declarative Vector transformations.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef VECTOR_TRANSFORM_PATTERNS
-#define VECTOR_TRANSFORM_PATTERNS
-
-include "mlir/IR/OpBase.td"
-
-class HasShape<list<int> shape> :
-  CPred<"$0.getType().cast<ShapedType>().hasStaticShape({" #
-    StrJoinInt<shape>.result # "})">;
-
-class UnrollVectorOp<list<int> factors> : NativeCodeCall<
-  "unrollSingleResultVectorOp($_builder, $0.getDefiningOp(), " #
-    "{" # StrJoinInt<factors>.result # "})">;
-
-#endif // VECTOR_TRANSFORM_PATTERNS
index d6ba987..7b34f19 100644 (file)
@@ -9,7 +9,6 @@ add_mlir_dialect_library(MLIRVector
 
   DEPENDS
   MLIRVectorOpsIncGen
-  MLIRVectorTransformPatternsIncGen
 
   LINK_LIBS PUBLIC
   MLIREDSC
index 641a621..0df357c 100644 (file)
@@ -1,4 +1,3 @@
-add_subdirectory(DeclarativeTransforms)
 add_subdirectory(Dialect)
 add_subdirectory(IR)
 add_subdirectory(Pass)
diff --git a/mlir/test/lib/DeclarativeTransforms/CMakeLists.txt b/mlir/test/lib/DeclarativeTransforms/CMakeLists.txt
deleted file mode 100644 (file)
index 67d194f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-set(LLVM_TARGET_DEFINITIONS TestVectorTransformPatterns.td)
-mlir_tablegen(TestVectorTransformPatterns.h.inc -gen-rewriters)
-add_public_tablegen_target(MLIRTestVectorTransformPatternsIncGen)
diff --git a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td b/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td
deleted file mode 100644 (file)
index 2c6ca1a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-//===- TestVectorTransformPatterns.td - Test patterns ---*- tablegen ----*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This is the pattern definition file for declarative Vector transformations
-// tests.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef TEST_VECTOR_TRANSFORMS_PATTERNS
-#define TEST_VECTOR_TRANSFORMS_PATTERNS
-
-include "mlir/Dialect/StandardOps/IR/Ops.td"
-include "mlir/Dialect/Vector/VectorOps.td"
-include "mlir/Dialect/Vector/VectorTransformPatterns.td"
-
-def : Pat<(AddFOp:$op_results $a, $b),
-          (UnrollVectorOp<[2, 2]> $op_results, $a, $b),
-          [(Constraint<HasShape<[4, 2]>> $a)]>;
-
-def : Pat<(AddFOp:$op_results $a, $b),
-          (UnrollVectorOp<[2, 2]> $op_results, $a, $b),
-          [(Constraint<HasShape<[4, 4]>> $a)]>;
-
-// TODO: Add Constraints on lhs/rhs shapes.
-def : Pat<(Vector_ContractionOp:$op_results $a, $b, $c, $masks, $attr0, $attr1),
-          (UnrollVectorOp<[2, 2, 2]> $op_results, $a, $b, $c),
-          [(Constraint<HasShape<[4, 4]>> $c)]>;
-
-#endif // TEST_VECTOR_TRANSFORMS_PATTERNS
diff --git a/mlir/test/lib/DeclarativeTransforms/lit.local.cfg b/mlir/test/lib/DeclarativeTransforms/lit.local.cfg
deleted file mode 100644 (file)
index edb5b44..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes.remove('.td')
\ No newline at end of file
index cdfd4e8..c331831 100644 (file)
@@ -32,7 +32,6 @@ add_mlir_library(MLIRTestTransforms
 
   DEPENDS
   MLIRStandardOpsIncGen
-  MLIRTestVectorTransformPatternsIncGen
 
   LINK_LIBS PUBLIC
   MLIRAffineOps
@@ -59,5 +58,3 @@ add_mlir_library(MLIRTestTransforms
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Dialect/Test)
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../Dialect/Test)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../DeclarativeTransforms)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/../DeclarativeTransforms)
index 2dffd88..2058706 100644 (file)
@@ -18,16 +18,16 @@ using namespace mlir;
 using namespace mlir::vector;
 namespace {
 
-#include "TestVectorTransformPatterns.h.inc"
-
 struct TestVectorToVectorConversion
     : public PassWrapper<TestVectorToVectorConversion, FunctionPass> {
   void runOnFunction() override {
     OwningRewritePatternList patterns;
-    auto *context = &getContext();
-    populateWithGenerated(context, &patterns);
-    populateVectorToVectorCanonicalizationPatterns(patterns, context);
-    populateVectorToVectorTransformationPatterns(patterns, context);
+    auto *ctx = &getContext();
+    patterns.insert<UnrollVectorPattern<AddFOp>>(ArrayRef<int64_t>{2, 2}, ctx);
+    patterns.insert<UnrollVectorPattern<vector::ContractionOp>>(
+        ArrayRef<int64_t>{2, 2, 2}, ctx);
+    populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
+    populateVectorToVectorTransformationPatterns(patterns, ctx);
     applyPatternsAndFoldGreedily(getFunction(), patterns);
   }
 };