[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
This commit is contained in:
Frederik Gossen 2020-07-24 11:17:43 +00:00
parent 5984d74139
commit bb442bb51a
4 changed files with 0 additions and 105 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)>;

View File

@ -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>)