[Mlir-commits] [mlir] 64cdd5b - [mlir][Vector] Drop declarative transforms
Nicolas Vasilache
llvmlistbot at llvm.org
Tue Jul 28 10:14:31 PDT 2020
Author: Nicolas Vasilache
Date: 2020-07-28T13:11:16-04:00
New Revision: 64cdd5b3da1abce63838bfc5bd32398c834a32e3
URL: https://github.com/llvm/llvm-project/commit/64cdd5b3da1abce63838bfc5bd32398c834a32e3
DIFF: https://github.com/llvm/llvm-project/commit/64cdd5b3da1abce63838bfc5bd32398c834a32e3.diff
LOG: [mlir][Vector] Drop declarative transforms
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
Added:
Modified:
mlir/include/mlir/Dialect/Vector/CMakeLists.txt
mlir/lib/Dialect/Vector/CMakeLists.txt
mlir/test/lib/CMakeLists.txt
mlir/test/lib/Transforms/CMakeLists.txt
mlir/test/lib/Transforms/TestVectorTransforms.cpp
Removed:
mlir/include/mlir/Dialect/Vector/VectorTransformPatterns.td
mlir/test/lib/DeclarativeTransforms/CMakeLists.txt
mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td
mlir/test/lib/DeclarativeTransforms/lit.local.cfg
################################################################################
diff --git a/mlir/include/mlir/Dialect/Vector/CMakeLists.txt b/mlir/include/mlir/Dialect/Vector/CMakeLists.txt
index a27eef693a28..23ad74e0cb72 100644
--- a/mlir/include/mlir/Dialect/Vector/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Vector/CMakeLists.txt
@@ -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
index ef8118ec6470..000000000000
--- a/mlir/include/mlir/Dialect/Vector/VectorTransformPatterns.td
+++ /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
diff --git a/mlir/lib/Dialect/Vector/CMakeLists.txt b/mlir/lib/Dialect/Vector/CMakeLists.txt
index d6ba987e6622..7b34f1933c42 100644
--- a/mlir/lib/Dialect/Vector/CMakeLists.txt
+++ b/mlir/lib/Dialect/Vector/CMakeLists.txt
@@ -9,7 +9,6 @@ add_mlir_dialect_library(MLIRVector
DEPENDS
MLIRVectorOpsIncGen
- MLIRVectorTransformPatternsIncGen
LINK_LIBS PUBLIC
MLIREDSC
diff --git a/mlir/test/lib/CMakeLists.txt b/mlir/test/lib/CMakeLists.txt
index 641a6218d1cc..0df357c8c355 100644
--- a/mlir/test/lib/CMakeLists.txt
+++ b/mlir/test/lib/CMakeLists.txt
@@ -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
index 67d194ff868a..000000000000
--- a/mlir/test/lib/DeclarativeTransforms/CMakeLists.txt
+++ /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
index 2c6ca1a05733..000000000000
--- a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td
+++ /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
index edb5b44b2e2f..000000000000
--- a/mlir/test/lib/DeclarativeTransforms/lit.local.cfg
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes.remove('.td')
\ No newline at end of file
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt
index cdfd4e8a815b..c3318316c508 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -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)
diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
index 2dffd88ed709..2058706dcbdd 100644
--- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
@@ -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);
}
};
More information about the Mlir-commits
mailing list