@@ -81,25 +81,6 @@ namespace mlir {
81
81
82
82
namespace {
83
83
84
- // TODO(b/355062942): This a temporary solution to unblock LLVM intergration.
85
- // https://github.com/llvm/llvm-project/commit/bbd4af5da2b741672a8e6f625eb12ea5c2d6220f
86
- // changed the behavior of `applySignatureConversion`. Before, an op adaptor
87
- // would have the new block arguments directly as operands. Now, there is an
88
- // `UnrealizedConversionCastOp` inserts from the new type to the old type.
89
- // The new behaviour is correct, but passes in this file depended on the old
90
- // bahavior and worked by coincidence.
91
- llvm::SmallVector<Value, 4 > GetOperandsAndSkipUnrealizedConversionCasts (
92
- ValueRange operands) {
93
- llvm::SmallVector<Value, 4 > result;
94
- for (Value operand : operands) {
95
- if (auto cast = operand.getDefiningOp <UnrealizedConversionCastOp>()) {
96
- operand = cast.getInputs ().front ();
97
- }
98
- result.push_back (operand);
99
- }
100
- return result;
101
- }
102
-
103
84
// / Lower TensorList ops in functions for subsequent legalization.
104
85
struct LowerStaticTensorListPass
105
86
: public impl::LowerStaticTensorListPassBase<LowerStaticTensorListPass> {
@@ -371,9 +352,7 @@ struct ConvertTensorListSetItem
371
352
ConversionPatternRewriter &rewriter) const {
372
353
Location loc = op.getLoc ();
373
354
374
- auto operands =
375
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
376
-
355
+ auto operands = adaptor.getOperands ();
377
356
Value input = operands[0 ];
378
357
Value index = operands[1 ];
379
358
Value item = operands[2 ];
@@ -433,8 +412,7 @@ struct ConvertTensorListSetItem
433
412
ConversionPatternRewriter &rewriter) const {
434
413
Location loc = op.getLoc ();
435
414
436
- auto operands =
437
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
415
+ auto operands = adaptor.getOperands ();
438
416
Value input = operands[0 ];
439
417
Value index = operands[1 ];
440
418
Value item = operands[2 ];
@@ -721,8 +699,7 @@ struct ConvertTensorListPushBack
721
699
LogicalResult matchAndRewrite (
722
700
TF::TensorListPushBackOp op, OpAdaptor adaptor,
723
701
ConversionPatternRewriter &rewriter) const override {
724
- auto operands =
725
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
702
+ auto operands = adaptor.getOperands ();
726
703
Value input_handle = operands[0 ];
727
704
Value item = operands[1 ];
728
705
@@ -764,8 +741,7 @@ struct ConvertTensorListResize
764
741
LogicalResult matchAndRewrite (
765
742
TF::TensorListResizeOp op, OpAdaptor adaptor,
766
743
ConversionPatternRewriter &rewriter) const override {
767
- auto operands =
768
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
744
+ auto operands = adaptor.getOperands ();
769
745
Value input_handle = operands[0 ];
770
746
Value size = operands[1 ];
771
747
@@ -929,9 +905,7 @@ struct ConvertTensorListGetItem
929
905
LogicalResult matchAndRewrite (
930
906
TF::TensorListGetItemOp op, OpAdaptor adaptor,
931
907
ConversionPatternRewriter &rewriter) const override {
932
- auto operands =
933
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
934
-
908
+ auto operands = adaptor.getOperands ();
935
909
Value input = operands[0 ];
936
910
Value index = operands[1 ];
937
911
rewriter.replaceOpWithNewOp <TF::GatherOp>(op, op.getType (), input, index,
@@ -948,8 +922,7 @@ struct ConvertTensorListLength
948
922
TF::TensorListLengthOp op, OpAdaptor adaptor,
949
923
ConversionPatternRewriter &rewriter) const override {
950
924
Location loc = op.getLoc ();
951
- Value input_handle =
952
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ())[0 ];
925
+ Value input_handle = adaptor.getOperands ()[0 ];
953
926
954
927
BoolAttr true_attr = rewriter.getBoolAttr (true );
955
928
auto shape = rewriter.create <TF::ShapeOp>(loc, input_handle,
@@ -970,8 +943,7 @@ struct ConvertTensorListStack
970
943
ConversionPatternRewriter &rewriter) const override {
971
944
Location loc = op.getLoc ();
972
945
973
- auto operands =
974
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
946
+ auto operands = adaptor.getOperands ();
975
947
Value input = operands[0 ];
976
948
Value element_shape = operands[1 ];
977
949
@@ -1021,8 +993,7 @@ struct ConvertTensorListConcatV2
1021
993
ConversionPatternRewriter &rewriter) const override {
1022
994
Location loc = op.getLoc ();
1023
995
1024
- auto operands =
1025
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
996
+ auto operands = adaptor.getOperands ();
1026
997
Value input = operands[0 ];
1027
998
Value element_shape = operands[1 ];
1028
999
@@ -1084,8 +1055,7 @@ struct ConvertIdentity : public OpConversionPattern<TF::IdentityOp> {
1084
1055
LogicalResult matchAndRewrite (
1085
1056
TF::IdentityOp op, OpAdaptor adaptor,
1086
1057
ConversionPatternRewriter &rewriter) const override {
1087
- Value input =
1088
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ())[0 ];
1058
+ Value input = adaptor.getOperands ()[0 ];
1089
1059
rewriter.replaceOpWithNewOp <TF::IdentityOp>(op, input.getType (), input,
1090
1060
op->getAttrs ());
1091
1061
return success ();
@@ -1098,9 +1068,7 @@ struct ConvertReturn : public OpConversionPattern<func::ReturnOp> {
1098
1068
LogicalResult matchAndRewrite (
1099
1069
func::ReturnOp op, OpAdaptor adaptor,
1100
1070
ConversionPatternRewriter &rewriter) const override {
1101
- auto operands =
1102
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
1103
-
1071
+ auto operands = adaptor.getOperands ();
1104
1072
rewriter.replaceOpWithNewOp <func::ReturnOp>(op, ValueRange{}, operands,
1105
1073
op->getAttrs ());
1106
1074
return success ();
@@ -1113,8 +1081,7 @@ struct ConvertYield : public OpConversionPattern<TF::YieldOp> {
1113
1081
LogicalResult matchAndRewrite (
1114
1082
TF::YieldOp op, OpAdaptor adaptor,
1115
1083
ConversionPatternRewriter &rewriter) const override {
1116
- auto operands =
1117
- GetOperandsAndSkipUnrealizedConversionCasts (adaptor.getOperands ());
1084
+ auto operands = adaptor.getOperands ();
1118
1085
rewriter.replaceOpWithNewOp <TF::YieldOp>(op, operands);
1119
1086
return success ();
1120
1087
}
0 commit comments