summaryrefslogtreecommitdiffstats
path: root/mlir/test/lib/Transforms
diff options
context:
space:
mode:
authorNicolas Vasilache <ntv@google.com>2019-11-20 10:54:45 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-20 11:49:36 -0800
commitfa14d4f6ab2ec069e43314a1769d21f374ccb4bd (patch)
tree242c890b2347ebb3d6981d9534c804399ceb0698 /mlir/test/lib/Transforms
parenteb418559ef29716cc34c891c93490c38ac5ea1dd (diff)
downloadbcm5719-llvm-fa14d4f6ab2ec069e43314a1769d21f374ccb4bd.tar.gz
bcm5719-llvm-fa14d4f6ab2ec069e43314a1769d21f374ccb4bd.zip
Implement unrolling of vector ops to finer-grained vector ops as a pattern.
This CL uses the pattern rewrite infrastructure to implement a simple VectorOps -> VectorOps legalization strategy to unroll coarse-grained vector operations into finer grained ones. The transformation is written using local pattern rewrites to allow composition with other rewrites. It proceeds by iteratively introducing fake cast ops and cleaning canonicalizing or lowering them away where appropriate. This is an example of writing transformations as compositions of local pattern rewrites that should enable us to make them significantly more declarative. PiperOrigin-RevId: 281555100
Diffstat (limited to 'mlir/test/lib/Transforms')
-rw-r--r--mlir/test/lib/Transforms/CMakeLists.txt1
-rw-r--r--mlir/test/lib/Transforms/TestVectorToVectorConversion.cpp44
-rw-r--r--mlir/test/lib/Transforms/TestVectorizationUtils.cpp2
3 files changed, 46 insertions, 1 deletions
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt
index 675b695aa7c..788b909d161 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -8,6 +8,7 @@ add_llvm_library(MLIRTestTransforms
TestLowerVectorTransfers.cpp
TestOpaqueLoc.cpp
TestMemRefStrideCalculation.cpp
+ TestVectorToVectorConversion.cpp
TestVectorizationUtils.cpp
ADDITIONAL_HEADER_DIRS
diff --git a/mlir/test/lib/Transforms/TestVectorToVectorConversion.cpp b/mlir/test/lib/Transforms/TestVectorToVectorConversion.cpp
new file mode 100644
index 00000000000..2550796ade2
--- /dev/null
+++ b/mlir/test/lib/Transforms/TestVectorToVectorConversion.cpp
@@ -0,0 +1,44 @@
+//===- TestVectorToVectorConversion.cpp - Test VectorTransfers lowering
+//-------===//
+//
+// 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.
+// =============================================================================
+
+#include <type_traits>
+
+#include "mlir/Conversion/VectorConversions/VectorConversions.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/Passes.h"
+
+using namespace mlir;
+
+namespace {
+
+struct TestVectorToVectorConversion
+ : public FunctionPass<TestVectorToVectorConversion> {
+ void runOnFunction() override {
+ OwningRewritePatternList patterns;
+ auto *context = &getContext();
+ populateVectorToVectorConversionPatterns(context, patterns);
+ applyPatternsGreedily(getFunction(), patterns);
+ }
+};
+
+} // end anonymous namespace
+
+static PassRegistration<TestVectorToVectorConversion>
+ pass("test-vector-to-vector-conversion",
+ "Test conversion patterns between ops in the vector dialect");
diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
index 4fdb66071bf..f0f1f6b0b23 100644
--- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
@@ -131,7 +131,7 @@ void VectorizerTestPass::testVectorShapeRatio(llvm::raw_ostream &outs) {
opInst->emitRemark("NOT MATCHED");
} else {
outs << "\nmatched: " << *opInst << " with shape ratio: ";
- interleaveComma(MutableArrayRef<unsigned>(*ratio), outs);
+ interleaveComma(MutableArrayRef<int64_t>(*ratio), outs);
}
}
}
OpenPOWER on IntegriCloud