diff --git a/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt b/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt --- 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 @@ DEPENDS MLIRConversionPassIncGen - ShapeToStandardPatternsIncGen LINK_COMPONENTS Core diff --git a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp --- 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 { @@ -108,24 +103,6 @@ return success(); } -namespace { -class ConstSizeOpConverter : public OpConversionPattern { -public: - using OpConversionPattern::OpConversionPattern; - - LogicalResult - matchAndRewrite(ConstSizeOp op, ArrayRef operands, - ConversionPatternRewriter &rewriter) const override; -}; -} // namespace - -LogicalResult ConstSizeOpConverter::matchAndRewrite( - ConstSizeOp op, ArrayRef operands, - ConversionPatternRewriter &rewriter) const { - rewriter.replaceOpWithNewOp(op, op.value().getSExtValue()); - return success(); -} - namespace { class GetExtentOpConverter : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -228,13 +205,11 @@ void mlir::populateShapeToStandardConversionPatterns( OwningRewritePatternList &patterns, MLIRContext *ctx) { - populateWithGenerated(ctx, &patterns); // clang-format off patterns.insert< AnyOpConversion, BinaryOpConversion, BinaryOpConversion, - 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 --- 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 --- a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir +++ b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir @@ -10,28 +10,6 @@ // ----- -// 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` type. // CHECK-LABEL: @shape_id // CHECK-SAME: (%[[SHAPE:.*]]: tensor) @@ -42,29 +20,6 @@ // ----- -// Lower `to_extent_tensor` operation to no-op. -// CHECK-LABEL: @to_extent_tensor -// CHECK-SAME: (%[[SHAPE:.*]]: tensor) -> tensor -func @to_extent_tensor(%shape : !shape.shape) -> tensor { - // CHECK-NEXT: return %[[SHAPE]] : tensor - %tensor = "shape.to_extent_tensor"(%shape) : (!shape.shape) -> tensor - return %tensor : tensor -} - -// ----- - -// Lower `from_extent_tensor` operation to no-op. -// CHECK-LABEL: @from_extent_tensor -// CHECK-SAME: (%[[TENSOR:.*]]: tensor) -> tensor -func @from_extent_tensor(%tensor : tensor) -> !shape.shape { - // CHECK-NEXT: return %[[TENSOR]] : tensor - %shape = "shape.from_extent_tensor"(%tensor) - : (tensor) -> !shape.shape - return %shape : !shape.shape -} - -// ----- - // Lower binary ops. // CHECK-LABEL: @binary_ops // CHECK-SAME: (%[[LHS:.*]]: index, %[[RHS:.*]]: index) @@ -78,16 +33,6 @@ // ----- -// 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>)