summaryrefslogtreecommitdiffstats
path: root/mlir/test/lib/Transforms
diff options
context:
space:
mode:
authorNicolas Vasilache <ntv@google.com>2019-11-21 06:29:41 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-21 06:40:17 -0800
commit2c4985816f4564f359d965a9c118b791f37dd5a4 (patch)
tree9db96ae6a9f20c8ec054c1c4e412f1e7a2ce95a6 /mlir/test/lib/Transforms
parentc2741d4ea0d3c0cc0305895e510ebc03c040b5fd (diff)
downloadbcm5719-llvm-2c4985816f4564f359d965a9c118b791f37dd5a4.tar.gz
bcm5719-llvm-2c4985816f4564f359d965a9c118b791f37dd5a4.zip
Split Linalg declarative patterns from specific test patterns - NFC
This will make it easier to scale out test patterns and build specific passes that do not interfere with independent testing. PiperOrigin-RevId: 281736335
Diffstat (limited to 'mlir/test/lib/Transforms')
-rw-r--r--mlir/test/lib/Transforms/CMakeLists.txt4
-rw-r--r--mlir/test/lib/Transforms/TestLinalgTransforms.cpp62
2 files changed, 66 insertions, 0 deletions
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt
index 788b909d161..2d482e5f1a5 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -3,6 +3,7 @@ add_llvm_library(MLIRTestTransforms
TestConstantFold.cpp
TestLoopFusion.cpp
TestInlining.cpp
+ TestLinalgTransforms.cpp
TestLoopMapping.cpp
TestLoopParametricTiling.cpp
TestLowerVectorTransfers.cpp
@@ -16,7 +17,10 @@ add_llvm_library(MLIRTestTransforms
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../TestDialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../TestDialect)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../DeclarativeTransforms)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../DeclarativeTransforms)
add_dependencies(MLIRTestTransforms MLIRStandardOpsIncGen)
+add_dependencies(MLIRTestTransforms MLIRTestLinalgTransformPatternsIncGen)
target_link_libraries(MLIRTestTransforms
MLIRAffineOps
MLIRAnalysis
diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
new file mode 100644
index 00000000000..37030ca2059
--- /dev/null
+++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
@@ -0,0 +1,62 @@
+//===- TestLinalgTransforms.cpp - Test Linalg transformation patterns -----===//
+//
+// Copyright 2019 The MLIR Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// =============================================================================
+//
+// This file implements logic for testing Linalg transformations.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
+#include "mlir/Dialect/Linalg/Transforms/LinalgTransforms.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+
+using namespace mlir;
+using namespace mlir::linalg;
+
+namespace mlir {
+namespace linalg {
+namespace {
+#include "TestLinalgTransformPatterns.h.inc"
+} // end namespace
+} // end namespace linalg
+} // end namespace mlir
+
+namespace {
+struct TestLinalgTransforms : public FunctionPass<TestLinalgTransforms> {
+ void runOnFunction() override;
+};
+} // end anonymous namespace
+
+/// Apply transformations specified as patterns.
+void TestLinalgTransforms::runOnFunction() {
+ OwningRewritePatternList patterns;
+ auto funcOp = getFunction();
+
+ // Add the generated patterns to the list.
+ linalg::populateWithGenerated(&getContext(), &patterns);
+ applyPatternsGreedily(funcOp, patterns);
+
+ // Drop the marker.
+ funcOp.walk([](LinalgOp op) {
+ op.removeAttr(LinalgTransforms::kLinalgTransformMarker);
+ });
+}
+
+static PassRegistration<TestLinalgTransforms>
+ pass("test-linalg-transform-patterns",
+ "Test Linalg transformation patterns by applying them greedily.");
OpenPOWER on IntegriCloud