diff options
| author | Jose Ignacio Gomez <jigomez@ucm.es> | 2019-12-05 15:14:22 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-05 15:14:59 -0800 |
| commit | f60bbb6c3b407b25367ce5bc5637b6edaf8c9e16 (patch) | |
| tree | f105f9a3bb05cbb390ae01113b7e8a8cd1759120 /mlir/test/lib/Transforms | |
| parent | da53000fb4191a3c1cef31d0b2faf4757a5dcfec (diff) | |
| download | bcm5719-llvm-f60bbb6c3b407b25367ce5bc5637b6edaf8c9e16.tar.gz bcm5719-llvm-f60bbb6c3b407b25367ce5bc5637b6edaf8c9e16.zip | |
[Linalg] Add permutation information to tiling
This patch closes issue tensorflow/mlir#271.
It adds an optional permutation map to declarative tiling transformations.
The map is expressed as a list of integers.
Closes tensorflow/mlir#288
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/288 from tetuante:issue271 2df2938d6a1f01b3bc404ded08dea2dd1e10b588
PiperOrigin-RevId: 284064151
Diffstat (limited to 'mlir/test/lib/Transforms')
| -rw-r--r-- | mlir/test/lib/Transforms/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | mlir/test/lib/Transforms/TestLinalgTilePermuteTransforms.cpp | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt index 8bc9c736187..8a7933451b8 100644 --- a/mlir/test/lib/Transforms/CMakeLists.txt +++ b/mlir/test/lib/Transforms/CMakeLists.txt @@ -4,6 +4,7 @@ add_llvm_library(MLIRTestTransforms TestLoopFusion.cpp TestInlining.cpp TestLinalgTransforms.cpp + TestLinalgTilePermuteTransforms.cpp TestLoopMapping.cpp TestLoopParametricTiling.cpp TestOpaqueLoc.cpp @@ -21,6 +22,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../DeclarativeTransforms) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../DeclarativeTransforms) add_dependencies(MLIRTestTransforms MLIRStandardOpsIncGen) add_dependencies(MLIRTestTransforms MLIRTestLinalgTransformPatternsIncGen) +add_dependencies(MLIRTestTransforms MLIRTestLinalgTilePermutePatternsIncGen) target_link_libraries(MLIRTestTransforms MLIRAffineOps MLIRAnalysis diff --git a/mlir/test/lib/Transforms/TestLinalgTilePermuteTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTilePermuteTransforms.cpp new file mode 100644 index 00000000000..ec7fa4e71b4 --- /dev/null +++ b/mlir/test/lib/Transforms/TestLinalgTilePermuteTransforms.cpp @@ -0,0 +1,64 @@ +//===- TestLinalgTilePermuteTransforms.cpp - Test Linalg tile + permute ---===// +// +// 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 "TestLinalgTilePermutePatterns.h.inc" +} // end namespace +} // end namespace linalg +} // end namespace mlir + +namespace { +struct TestLinalgTilePermuteTransforms + : public FunctionPass<TestLinalgTilePermuteTransforms> { + void runOnFunction() override; +}; +} // end anonymous namespace + +/// Apply transformations specified as patterns. +void TestLinalgTilePermuteTransforms::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<TestLinalgTilePermuteTransforms> + pass("test-linalg-tile-and-permute-patterns", + "Test Linalg transformation with permutation patterns by applying " + "them greedily."); |

