[Mlir-commits] [mlir] 7c234ae - [mlir][linalg] Cleanup LinalgOp usage in bufferize, detensorize, and interchange.
Tobias Gysi
llvmlistbot at llvm.org
Thu Jun 3 05:08:14 PDT 2021
Author: Tobias Gysi
Date: 2021-06-03T12:07:29Z
New Revision: 7c234ae549eadcf362f82198d5416d0019d9690c
URL: https://github.com/llvm/llvm-project/commit/7c234ae549eadcf362f82198d5416d0019d9690c
DIFF: https://github.com/llvm/llvm-project/commit/7c234ae549eadcf362f82198d5416d0019d9690c.diff
LOG: [mlir][linalg] Cleanup LinalgOp usage in bufferize, detensorize, and interchange.
Replace the uses of deprecated Structured Op Interface methods in Bufferize.cpp, Detensorize.cpp, and Interchange.cpp. The patch is based on https://reviews.llvm.org/D103394.
Differential Revision: https://reviews.llvm.org/D103530
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
index 1e627fe1ed82..757f336a22c0 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
@@ -54,7 +54,8 @@ allocateBuffersForResults(Location loc, LinalgOp linalgOp, ValueRange outputs,
Value resultTensor = outputs[resultIndex];
// Clone output buffers whose value is actually used.
- if (linalgOp.payloadUsesValueFromOutputOperandIndex(resultIndex)) {
+ OpOperand *tiedOpOperand = linalgOp.getOutputOperand(resultIndex);
+ if (linalgOp.payloadUsesValueFromOperand(tiedOpOperand)) {
resultBuffers.push_back(cloneMemref(loc, resultTensor, b));
continue;
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
index c4056d910384..fd26f671c9b9 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
@@ -48,10 +48,11 @@ bool canBeDetensored(TensorType tensorType) {
bool shouldBeDetensored(Operation *op, TypeConverter typeConverter) {
GenericOp genericOp = dyn_cast_or_null<GenericOp>(op);
- return genericOp && llvm::all_of(genericOp.getShapedOperandTypes(),
- [&](ShapedType shapedType) {
- return !typeConverter.isLegal(shapedType);
- });
+ return genericOp &&
+ llvm::all_of(
+ genericOp.getInputAndOutputOperands(), [&](OpOperand *opOperand) {
+ return !typeConverter.isLegal(opOperand->get().getType());
+ });
}
/// A conversion patttern for detensoring `linalg.generic` ops.
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp b/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
index add8b40bb861..d94fa30500b7 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
@@ -56,9 +56,8 @@ void mlir::linalg::interchangeGenericOp(PatternRewriter &rewriter,
// 2. Compute the interchanged indexing maps.
SmallVector<Attribute, 4> newIndexingMaps;
- ArrayRef<Attribute> indexingMaps = genericOp.indexing_maps().getValue();
- for (unsigned i = 0, e = genericOp.getNumShapedOperands(); i != e; ++i) {
- AffineMap m = indexingMaps[i].cast<AffineMapAttr>().getValue();
+ for (OpOperand *opOperand : genericOp.getInputAndOutputOperands()) {
+ AffineMap m = genericOp.getTiedIndexingMap(opOperand);
if (!permutationMap.isEmpty())
m = m.compose(permutationMap);
newIndexingMaps.push_back(AffineMapAttr::get(m));
More information about the Mlir-commits
mailing list