Skip to content

Commit 07919cf

Browse files
authored
Revert "[mlir][vector] Make TransposeOpLowering configurable (#73915)" (#75062)
Reverting a workaround intended specifically for SPRI-V. That workaround emerged from this discussion: * #72105 AFAIK, it hasn't been required in practice. This is based on IREE (https://github.com/openxla/iree), which has just bumped it's fork of LLVM without using it (*). (*) iree-org/iree@cef31e7 This reverts commit bbd2b08.
1 parent 13ef4fe commit 07919cf

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ struct VectorTransformsOptions {
5959
vectorTransferSplit = opt;
6060
return *this;
6161
}
62-
63-
/// Option to control if vector.transpose can lower to a vector.shape_cast.
64-
/// TODO: ATM it's not possible to lower `vector.shape_cast` to SPIR-V
65-
/// and hence the need for this opt-out. Once the missing support has been
66-
/// added, this option can be removed.
67-
bool useShapeCast = true;
68-
VectorTransformsOptions &setUseShapeCast(bool opt = true) {
69-
useShapeCast = opt;
70-
return *this;
71-
}
7262
};
7363

7464
//===----------------------------------------------------------------------===//

mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,24 +334,22 @@ class TransposeOpLowering : public OpRewritePattern<vector::TransposeOp> {
334334
return rewriter.notifyMatchFailure(
335335
op, "Options specifies lowering to shuffle");
336336

337-
if (vectorTransformOptions.useShapeCast) {
338-
// Replace:
339-
// vector.transpose %0, [1, 0] : vector<nx1x<eltty>> to
340-
// vector<1xnxelty>
341-
// with:
342-
// vector.shape_cast %0 : vector<nx1x<eltty>> to vector<1xnxelty>
343-
//
344-
// Source with leading unit dim (inverse) is also replaced. Unit dim must
345-
// be fixed. Non-unit can be scalable.
346-
if (resType.getRank() == 2 &&
347-
((resType.getShape().front() == 1 &&
348-
!resType.getScalableDims().front()) ||
349-
(resType.getShape().back() == 1 &&
350-
!resType.getScalableDims().back())) &&
351-
transp == ArrayRef<int64_t>({1, 0})) {
352-
rewriter.replaceOpWithNewOp<vector::ShapeCastOp>(op, resType, input);
353-
return success();
354-
}
337+
// Replace:
338+
// vector.transpose %0, [1, 0] : vector<nx1x<eltty>> to
339+
// vector<1xnxelty>
340+
// with:
341+
// vector.shape_cast %0 : vector<nx1x<eltty>> to vector<1xnxelty>
342+
//
343+
// Source with leading unit dim (inverse) is also replaced. Unit dim must
344+
// be fixed. Non-unit can be scalable.
345+
if (resType.getRank() == 2 &&
346+
((resType.getShape().front() == 1 &&
347+
!resType.getScalableDims().front()) ||
348+
(resType.getShape().back() == 1 &&
349+
!resType.getScalableDims().back())) &&
350+
transp == ArrayRef<int64_t>({1, 0})) {
351+
rewriter.replaceOpWithNewOp<vector::ShapeCastOp>(op, resType, input);
352+
return success();
355353
}
356354

357355
if (inputType.isScalable())

0 commit comments

Comments
 (0)