Skip to content

Commit bb442bb

Browse files
committed
[MLIR][Shape] Remove deprecated and unused lowerings
This concerns `from/to_extent_tensor`, `size_to_index`, `index_to_size`, and `const_size` conversion patterns. The new lowering will work directly on indices and extent tensors. The shape and size values will allow for error values but are not yet supported by the dialect conversion. Differential Revision: https://reviews.llvm.org/D84436
1 parent 5984d74 commit bb442bb

File tree

4 files changed

+0
-105
lines changed

4 files changed

+0
-105
lines changed

mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
set(LLVM_TARGET_DEFINITIONS ShapeToStandardPatterns.td)
2-
mlir_tablegen(ShapeToStandardPatterns.inc -gen-rewriters)
3-
add_public_tablegen_target(ShapeToStandardPatternsIncGen)
4-
51
add_mlir_conversion_library(MLIRShapeToStandard
62
ShapeToStandard.cpp
73

@@ -10,7 +6,6 @@ add_mlir_conversion_library(MLIRShapeToStandard
106

117
DEPENDS
128
MLIRConversionPassIncGen
13-
ShapeToStandardPatternsIncGen
149

1510
LINK_COMPONENTS
1611
Core

mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
using namespace mlir;
1818
using namespace mlir::shape;
1919

20-
namespace {
21-
/// Generated conversion patterns.
22-
#include "ShapeToStandardPatterns.inc"
23-
} // namespace
24-
2520
/// Conversion patterns.
2621
namespace {
2722
class AnyOpConversion : public OpConversionPattern<AnyOp> {
@@ -108,24 +103,6 @@ LogicalResult ShapeOfOpConversion::matchAndRewrite(
108103
return success();
109104
}
110105

111-
namespace {
112-
class ConstSizeOpConverter : public OpConversionPattern<ConstSizeOp> {
113-
public:
114-
using OpConversionPattern<ConstSizeOp>::OpConversionPattern;
115-
116-
LogicalResult
117-
matchAndRewrite(ConstSizeOp op, ArrayRef<Value> operands,
118-
ConversionPatternRewriter &rewriter) const override;
119-
};
120-
} // namespace
121-
122-
LogicalResult ConstSizeOpConverter::matchAndRewrite(
123-
ConstSizeOp op, ArrayRef<Value> operands,
124-
ConversionPatternRewriter &rewriter) const {
125-
rewriter.replaceOpWithNewOp<ConstantIndexOp>(op, op.value().getSExtValue());
126-
return success();
127-
}
128-
129106
namespace {
130107
class GetExtentOpConverter : public OpConversionPattern<GetExtentOp> {
131108
using OpConversionPattern<GetExtentOp>::OpConversionPattern;
@@ -228,13 +205,11 @@ void ConvertShapeToStandardPass::runOnOperation() {
228205

229206
void mlir::populateShapeToStandardConversionPatterns(
230207
OwningRewritePatternList &patterns, MLIRContext *ctx) {
231-
populateWithGenerated(ctx, &patterns);
232208
// clang-format off
233209
patterns.insert<
234210
AnyOpConversion,
235211
BinaryOpConversion<AddOp, AddIOp>,
236212
BinaryOpConversion<MulOp, MulIOp>,
237-
ConstSizeOpConverter,
238213
GetExtentOpConverter,
239214
RankOpConverter,
240215
ShapeOfOpConversion>(ctx);

mlir/lib/Conversion/ShapeToStandard/ShapeToStandardPatterns.td

Lines changed: 0 additions & 20 deletions
This file was deleted.

mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,6 @@ func @size_id(%size : !shape.size) -> !shape.size {
1010

1111
// -----
1212

13-
// Lower `size_to_index` conversion to no-op.
14-
// CHECK-LABEL: @size_to_index
15-
// CHECK-SAME: (%[[SIZE:.*]]: index) -> index
16-
func @size_to_index(%size : !shape.size) -> index {
17-
// CHECK-NEXT: return %[[SIZE]] : index
18-
%index = shape.size_to_index %size
19-
return %index : index
20-
}
21-
22-
// -----
23-
24-
// Lower `index_to_size` conversion to no-op.
25-
// CHECK-LABEL: @index_to_size
26-
// CHECK-SAME: (%[[INDEX:.*]]: index) -> index
27-
func @index_to_size(%index : index) -> !shape.size {
28-
// CHECK-NEXT: return %[[INDEX]] : index
29-
%size = shape.index_to_size %index
30-
return %size : !shape.size
31-
}
32-
33-
// -----
34-
3513
// Convert `shape` to `tensor<?xindex>` type.
3614
// CHECK-LABEL: @shape_id
3715
// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>)
@@ -42,29 +20,6 @@ func @shape_id(%shape : !shape.shape) -> !shape.shape {
4220

4321
// -----
4422

45-
// Lower `to_extent_tensor` operation to no-op.
46-
// CHECK-LABEL: @to_extent_tensor
47-
// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>) -> tensor<?xindex>
48-
func @to_extent_tensor(%shape : !shape.shape) -> tensor<?xindex> {
49-
// CHECK-NEXT: return %[[SHAPE]] : tensor<?xindex>
50-
%tensor = "shape.to_extent_tensor"(%shape) : (!shape.shape) -> tensor<?xindex>
51-
return %tensor : tensor<?xindex>
52-
}
53-
54-
// -----
55-
56-
// Lower `from_extent_tensor` operation to no-op.
57-
// CHECK-LABEL: @from_extent_tensor
58-
// CHECK-SAME: (%[[TENSOR:.*]]: tensor<?xindex>) -> tensor<?xindex>
59-
func @from_extent_tensor(%tensor : tensor<?xindex>) -> !shape.shape {
60-
// CHECK-NEXT: return %[[TENSOR]] : tensor<?xindex>
61-
%shape = "shape.from_extent_tensor"(%tensor)
62-
: (tensor<?xindex>) -> !shape.shape
63-
return %shape : !shape.shape
64-
}
65-
66-
// -----
67-
6823
// Lower binary ops.
6924
// CHECK-LABEL: @binary_ops
7025
// CHECK-SAME: (%[[LHS:.*]]: index, %[[RHS:.*]]: index)
@@ -78,16 +33,6 @@ func @binary_ops(%lhs : !shape.size, %rhs : !shape.size) {
7833

7934
// -----
8035

81-
// Convert `const_size` to `constant` op.
82-
// CHECK-LABEL: @size_const
83-
func @size_const() -> !shape.size {
84-
%c1 = shape.const_size 1
85-
return %c1 : !shape.size
86-
}
87-
// CHECK: %[[C1:.*]] = constant 1 : index
88-
// CHECK: return %[[C1]] : index
89-
// -----
90-
9136
// Lower `shape_of` for statically shaped tensor.
9237
// CHECK-LABEL: @shape_of_stat
9338
// CHECK-SAME: (%[[ARG:.*]]: tensor<1x2x3xf32>)

0 commit comments

Comments
 (0)