[Mlir-commits] [mlir] bb442bb - [MLIR][Shape] Remove deprecated and unused lowerings
Frederik Gossen
llvmlistbot at llvm.org
Fri Jul 24 04:20:03 PDT 2020
Author: Frederik Gossen
Date: 2020-07-24T11:19:36Z
New Revision: bb442bb51ac3795fa5aca803fe9160742186cc54
URL: https://github.com/llvm/llvm-project/commit/bb442bb51ac3795fa5aca803fe9160742186cc54
DIFF: https://github.com/llvm/llvm-project/commit/bb442bb51ac3795fa5aca803fe9160742186cc54.diff
LOG: [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
Added:
Modified:
mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt
mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
Removed:
mlir/lib/Conversion/ShapeToStandard/ShapeToStandardPatterns.td
################################################################################
diff --git a/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt b/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt
index 4d97af2f235c..8750c331859e 100644
--- a/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt
+++ b/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt
@@ -1,7 +1,3 @@
-set(LLVM_TARGET_DEFINITIONS ShapeToStandardPatterns.td)
-mlir_tablegen(ShapeToStandardPatterns.inc -gen-rewriters)
-add_public_tablegen_target(ShapeToStandardPatternsIncGen)
-
add_mlir_conversion_library(MLIRShapeToStandard
ShapeToStandard.cpp
@@ -10,7 +6,6 @@ add_mlir_conversion_library(MLIRShapeToStandard
DEPENDS
MLIRConversionPassIncGen
- ShapeToStandardPatternsIncGen
LINK_COMPONENTS
Core
diff --git a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
index 5a974bc9365e..f239d1cfb4f0 100644
--- a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
+++ b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
@@ -17,11 +17,6 @@
using namespace mlir;
using namespace mlir::shape;
-namespace {
-/// Generated conversion patterns.
-#include "ShapeToStandardPatterns.inc"
-} // namespace
-
/// Conversion patterns.
namespace {
class AnyOpConversion : public OpConversionPattern<AnyOp> {
@@ -108,24 +103,6 @@ LogicalResult ShapeOfOpConversion::matchAndRewrite(
return success();
}
-namespace {
-class ConstSizeOpConverter : public OpConversionPattern<ConstSizeOp> {
-public:
- using OpConversionPattern<ConstSizeOp>::OpConversionPattern;
-
- LogicalResult
- matchAndRewrite(ConstSizeOp op, ArrayRef<Value> operands,
- ConversionPatternRewriter &rewriter) const override;
-};
-} // namespace
-
-LogicalResult ConstSizeOpConverter::matchAndRewrite(
- ConstSizeOp op, ArrayRef<Value> operands,
- ConversionPatternRewriter &rewriter) const {
- rewriter.replaceOpWithNewOp<ConstantIndexOp>(op, op.value().getSExtValue());
- return success();
-}
-
namespace {
class GetExtentOpConverter : public OpConversionPattern<GetExtentOp> {
using OpConversionPattern<GetExtentOp>::OpConversionPattern;
@@ -228,13 +205,11 @@ void ConvertShapeToStandardPass::runOnOperation() {
void mlir::populateShapeToStandardConversionPatterns(
OwningRewritePatternList &patterns, MLIRContext *ctx) {
- populateWithGenerated(ctx, &patterns);
// clang-format off
patterns.insert<
AnyOpConversion,
BinaryOpConversion<AddOp, AddIOp>,
BinaryOpConversion<MulOp, MulIOp>,
- ConstSizeOpConverter,
GetExtentOpConverter,
RankOpConverter,
ShapeOfOpConversion>(ctx);
diff --git a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandardPatterns.td b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandardPatterns.td
deleted file mode 100644
index 30bed6d7fb65..000000000000
--- a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandardPatterns.td
+++ /dev/null
@@ -1,20 +0,0 @@
-include "mlir/Dialect/Shape/IR/ShapeOps.td"
-include "mlir/Dialect/StandardOps/IR/Ops.td"
-
-// Convert `from_extent_tensor` and `to_extent_tensor` to no-ops as shapes will
-// be represented as extent tensors.
-def FromExtentTensorOpConversion : Pat<
- (Shape_FromExtentTensorOp $input),
- (replaceWithValue $input)>;
-def ToExtentTensorOpConversion : Pat<
- (Shape_ToExtentTensorOp $input),
- (replaceWithValue $input)>;
-
-// Convert `index_to_size` and `size_to_index` to no-ops as sizes will be
-// represented as indices.
-def IndexToSizeOpConversion : Pat<
- (Shape_IndexToSizeOp $arg),
- (replaceWithValue $arg)>;
-def SizeToIndexOpConversion : Pat<
- (Shape_SizeToIndexOp $arg),
- (replaceWithValue $arg)>;
diff --git a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
index 441024e9773e..908acabe5345 100644
--- a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
+++ b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
@@ -10,28 +10,6 @@ func @size_id(%size : !shape.size) -> !shape.size {
// -----
-// Lower `size_to_index` conversion to no-op.
-// CHECK-LABEL: @size_to_index
-// CHECK-SAME: (%[[SIZE:.*]]: index) -> index
-func @size_to_index(%size : !shape.size) -> index {
- // CHECK-NEXT: return %[[SIZE]] : index
- %index = shape.size_to_index %size
- return %index : index
-}
-
-// -----
-
-// Lower `index_to_size` conversion to no-op.
-// CHECK-LABEL: @index_to_size
-// CHECK-SAME: (%[[INDEX:.*]]: index) -> index
-func @index_to_size(%index : index) -> !shape.size {
- // CHECK-NEXT: return %[[INDEX]] : index
- %size = shape.index_to_size %index
- return %size : !shape.size
-}
-
-// -----
-
// Convert `shape` to `tensor<?xindex>` type.
// CHECK-LABEL: @shape_id
// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>)
@@ -42,29 +20,6 @@ func @shape_id(%shape : !shape.shape) -> !shape.shape {
// -----
-// Lower `to_extent_tensor` operation to no-op.
-// CHECK-LABEL: @to_extent_tensor
-// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>) -> tensor<?xindex>
-func @to_extent_tensor(%shape : !shape.shape) -> tensor<?xindex> {
- // CHECK-NEXT: return %[[SHAPE]] : tensor<?xindex>
- %tensor = "shape.to_extent_tensor"(%shape) : (!shape.shape) -> tensor<?xindex>
- return %tensor : tensor<?xindex>
-}
-
-// -----
-
-// Lower `from_extent_tensor` operation to no-op.
-// CHECK-LABEL: @from_extent_tensor
-// CHECK-SAME: (%[[TENSOR:.*]]: tensor<?xindex>) -> tensor<?xindex>
-func @from_extent_tensor(%tensor : tensor<?xindex>) -> !shape.shape {
- // CHECK-NEXT: return %[[TENSOR]] : tensor<?xindex>
- %shape = "shape.from_extent_tensor"(%tensor)
- : (tensor<?xindex>) -> !shape.shape
- return %shape : !shape.shape
-}
-
-// -----
-
// Lower binary ops.
// CHECK-LABEL: @binary_ops
// CHECK-SAME: (%[[LHS:.*]]: index, %[[RHS:.*]]: index)
@@ -78,16 +33,6 @@ func @binary_ops(%lhs : !shape.size, %rhs : !shape.size) {
// -----
-// Convert `const_size` to `constant` op.
-// CHECK-LABEL: @size_const
-func @size_const() -> !shape.size {
- %c1 = shape.const_size 1
- return %c1 : !shape.size
-}
-// CHECK: %[[C1:.*]] = constant 1 : index
-// CHECK: return %[[C1]] : index
-// -----
-
// Lower `shape_of` for statically shaped tensor.
// CHECK-LABEL: @shape_of_stat
// CHECK-SAME: (%[[ARG:.*]]: tensor<1x2x3xf32>)
More information about the Mlir-commits
mailing list