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/lib/IR | |
| 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/lib/IR')
| -rw-r--r-- | mlir/lib/IR/AffineMap.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index e56d0e83f65..98357b1348b 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -106,6 +106,20 @@ AffineMap AffineMap::getConstantMap(int64_t val, MLIRContext *context) { {getAffineConstantExpr(val, context)}); } +/// Returns an AffineMap representing a permutation. +AffineMap AffineMap::getPermutationMap(ArrayRef<unsigned> permutation, + MLIRContext *context) { + assert(!permutation.empty() && + "Cannot create permutation map from empty permutation vector"); + SmallVector<AffineExpr, 4> affExprs; + for (auto index : permutation) + affExprs.push_back(getAffineDimExpr(index, context)); + auto m = std::max_element(permutation.begin(), permutation.end()); + auto permutationMap = AffineMap::get(*m + 1, 0, affExprs); + assert(permutationMap.isPermutation() && "Invalid permutation vector"); + return permutationMap; +} + AffineMap AffineMap::getMultiDimIdentityMap(unsigned numDims, MLIRContext *context) { SmallVector<AffineExpr, 4> dimExprs; |

