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
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)
+++ /dev/null
-//===- 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
DEPENDS
MLIRVectorOpsIncGen
- MLIRVectorTransformPatternsIncGen
LINK_LIBS PUBLIC
MLIREDSC
-add_subdirectory(DeclarativeTransforms)
add_subdirectory(Dialect)
add_subdirectory(IR)
add_subdirectory(Pass)
+++ /dev/null
-set(LLVM_TARGET_DEFINITIONS TestVectorTransformPatterns.td)
-mlir_tablegen(TestVectorTransformPatterns.h.inc -gen-rewriters)
-add_public_tablegen_target(MLIRTestVectorTransformPatternsIncGen)
+++ /dev/null
-//===- 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
+++ /dev/null
-config.suffixes.remove('.td')
\ No newline at end of file
DEPENDS
MLIRStandardOpsIncGen
- MLIRTestVectorTransformPatternsIncGen
LINK_LIBS PUBLIC
MLIRAffineOps
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)
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);
}
};