Skip to content

Commit 2e1efba

Browse files
abatterytensorflower-gardener
authored andcommitted
Convert TF Broadcast op to the corresponding TFL Broadcast op when 5+ dimension inputs are given.
Low dimension, where its rank is at most 4, will be handled by the Mul op as usual in order not to break acceleration support. PiperOrigin-RevId: 322539601 Change-Id: Ic4b249b64ef02aecef57f0ac7a0354e7c67a8799
1 parent d42d8c5 commit 2e1efba

11 files changed

Lines changed: 359 additions & 123 deletions

File tree

‎tensorflow/compiler/mlir/lite/BUILD‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,28 @@ cc_library(
237237
alwayslink = 1,
238238
)
239239

240+
cc_library(
241+
name = "constant_utils",
242+
srcs = [
243+
"utils/constant_utils.cc",
244+
],
245+
hdrs = [
246+
"utils/constant_utils.h",
247+
],
248+
copts = ["-std=c++14"],
249+
deps = [
250+
"//tensorflow/compiler/mlir/tensorflow",
251+
"//tensorflow/compiler/mlir/tensorflow:mangling_util",
252+
"//tensorflow/compiler/xla:statusor",
253+
"//tensorflow/core:protos_all_cc",
254+
"//tensorflow/core/platform:status",
255+
"@llvm-project//llvm:Support",
256+
"@llvm-project//mlir:IR",
257+
"@llvm-project//mlir:StandardOps",
258+
"@llvm-project//mlir:Support",
259+
],
260+
)
261+
240262
cc_library(
241263
name = "lstm_utils",
242264
srcs = [
@@ -346,6 +368,7 @@ cc_library(
346368
"transforms/passes.h",
347369
],
348370
deps = [
371+
":constant_utils",
349372
":lstm_utils",
350373
":stateful_ops_utils",
351374
":tensorflow_lite",

‎tensorflow/compiler/mlir/lite/ir/tfl_ops.td‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4345,4 +4345,55 @@ def TFL_CustomTfOp : Op<TFL_Dialect, "custom_tf", [
43454345
let regions = (region SizedRegion<1>:$body);
43464346
}
43474347

4348+
def TFL_BroadcastToOp : TFL_Op<"broadcast_to", [
4349+
PredOpTrait<"input and output must have same element type",
4350+
TFL_TCresVTEtIsSameAsOp<0, 0>>,
4351+
TFL_OperandHasRankAtMost<0, 8>,
4352+
TFL_OperandHasRank<1, 1>,
4353+
PredOpTrait<"output dimension count must be at most 8",
4354+
Or<[TFL_OperandIsUnrankedPred<1>,
4355+
TFL_OperandDimIsAtMost<1, 0, 8>]>>,
4356+
NoSideEffect]> {
4357+
let summary = "Broadcast an array for a compatible shape.";
4358+
4359+
let description = [{
4360+
Broadcasting is the process of making arrays to have compatible shapes
4361+
for arithmetic operations. Two shapes are compatible if for each
4362+
dimension pair they are either equal or one of them is one. When trying
4363+
to broadcast a Tensor to a shape, it starts with the trailing dimensions,
4364+
and works its way forward.
4365+
4366+
For example,
4367+
4368+
>>> x = tf.constant([1, 2, 3])
4369+
>>> y = tf.broadcast_to(x, [3, 3])
4370+
>>> print(y)
4371+
tf.Tensor(
4372+
[[1 2 3]
4373+
[1 2 3]
4374+
[1 2 3]], shape=(3, 3), dtype=int32)
4375+
4376+
In the above example, the input Tensor with the shape of `[1, 3]`
4377+
is broadcasted to output Tensor with shape of `[3, 3]`.
4378+
4379+
When doing broadcasted operations such as multiplying a tensor
4380+
by a scalar, broadcasting (usually) confers some time or space
4381+
benefit, as the broadcasted tensor is never materialized.
4382+
4383+
However, `broadcast_to` does not carry with it any such benefits.
4384+
The newly-created tensor takes the full memory of the broadcasted
4385+
shape. (In a graph context, `broadcast_to` might be fused to
4386+
subsequent operation and then be optimized away, however.)
4387+
}];
4388+
4389+
let arguments = (ins
4390+
TFL_TensorOf<[F32, I32, I1, I8, QI8, UI8, QUI8, I16, QI16, I64, Complex<F<32>>]>:$input,
4391+
TFL_I32OrI64Tensor:$shape
4392+
);
4393+
4394+
let results = (outs
4395+
TFL_TensorOf<[F32, I32, I1, I8, QI8, UI8, QUI8, I16, QI16, I64, Complex<F<32>>]>:$output
4396+
);
4397+
}
4398+
43484399
#endif // TFL_OPS

‎tensorflow/compiler/mlir/lite/tests/legalize-tf-no-runtime-verification.mlir‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ func @broadcast_to_bf16(%arg0: tensor<3xbf16>, %arg1: tensor<2xi64>) -> tensor<3
55
return %0: tensor<3x3xbf16>
66

77
// CHECK-LABEL: broadcast_to_bf16
8-
// CHECK: [[CST:%.*]] = constant dense<1.000000e+00> : tensor<bf16>
9-
// CHECK: [[FILL:%.*]] = "tfl.fill"(%arg1, [[CST]]) : (tensor<2xi64>, tensor<bf16>) -> tensor<3x3xbf16>
10-
// CHECK: [[MUL:%.*]] = "tfl.mul"(%arg0, [[FILL]]) {fused_activation_function = "NONE"} : (tensor<3xbf16>, tensor<3x3xbf16>) -> tensor<3x3xbf16>
11-
// CHECK: return [[MUL]] : tensor<3x3xbf16>
8+
// CHECK: [[BCT:%.*]] = "tfl.broadcast_to"(%arg0, %arg1) : (tensor<3xbf16>, tensor<2xi64>) -> tensor<3x3xbf16>
9+
// CHECK: return [[BCT]] : tensor<3x3xbf16>
1210
}

‎tensorflow/compiler/mlir/lite/tests/legalize-tf.mlir‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,21 +1487,17 @@ func @broadcast_to_f32(%arg0: tensor<3xf32>, %arg1: tensor<2xi32>) -> tensor<3x3
14871487
return %0: tensor<3x3xf32>
14881488

14891489
// CHECK-LABEL: broadcast_to_f32
1490-
// CHECK: [[CST:%.*]] = constant dense<1.000000e+00> : tensor<f32>
1491-
// CHECK: [[FILL:%.*]] = "tfl.fill"(%arg1, [[CST]]) : (tensor<2xi32>, tensor<f32>) -> tensor<3x3xf32>
1492-
// CHECK: [[MUL:%.*]] = "tfl.mul"(%arg0, [[FILL]]) {fused_activation_function = "NONE"} : (tensor<3xf32>, tensor<3x3xf32>) -> tensor<3x3xf32>
1493-
// CHECK: return [[MUL]] : tensor<3x3xf32>
1490+
// CHECK: [[BCT:%.*]] = "tfl.broadcast_to"(%arg0, %arg1) : (tensor<3xf32>, tensor<2xi32>) -> tensor<3x3xf32>
1491+
// CHECK: return [[BCT]] : tensor<3x3xf32>
14941492
}
14951493

14961494
func @broadcast_to_i32(%input: tensor<3xi32>, %shape: tensor<2xi32>) -> tensor<3x3xi32> {
14971495
%0 = "tf.BroadcastTo"(%input, %shape) : (tensor<3xi32>, tensor<2xi32>) -> tensor<3x3xi32>
14981496
return %0: tensor<3x3xi32>
14991497

15001498
// CHECK-LABEL: broadcast_to_i32
1501-
// CHECK: [[CST:%.*]] = constant dense<1> : tensor<i32>
1502-
// CHECK: [[FILL:%.*]] = "tfl.fill"(%arg1, [[CST]]) : (tensor<2xi32>, tensor<i32>) -> tensor<3x3xi32>
1503-
// CHECK: [[MUL:%.*]] = "tfl.mul"(%arg0, [[FILL]]) {fused_activation_function = "NONE"} : (tensor<3xi32>, tensor<3x3xi32>) -> tensor<3x3xi32>
1504-
// CHECK: return [[MUL]] : tensor<3x3xi32>
1499+
// CHECK: [[BCT:%.*]] = "tfl.broadcast_to"(%arg0, %arg1) : (tensor<3xi32>, tensor<2xi32>) -> tensor<3x3xi32>
1500+
// CHECK: return [[BCT]] : tensor<3x3xi32>
15051501
}
15061502

15071503
func @matmul_batch(%arg0: tensor<10x15xf32>, %arg1: tensor<15x17xf32>) -> tensor<10x17xf32> {

‎tensorflow/compiler/mlir/lite/tests/ops.mlir‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,3 +2310,21 @@ func @main(%arg0: tensor<i32>, %arg1: tensor<1xf32>) -> tensor<i32> {
23102310
}) : (tensor<i32>, tensor<1xf32>) -> (tensor<i32>)
23112311
return %0#0 : tensor<i32>
23122312
}
2313+
2314+
// -----
2315+
2316+
// CHECK-LABEL: testBroadcastToWithI32ShapeTensor
2317+
func @testBroadcastToWithI32ShapeTensor(tensor<?x?x?x?x?x?xf32>, tensor<8xi32>) -> tensor<?x?x?x?x?x?x?x?xf32> {
2318+
^bb0(%arg0: tensor<?x?x?x?x?x?xf32>, %arg1: tensor<8xi32>):
2319+
// CHECK: "tfl.broadcast_to"(%arg0, %arg1)
2320+
%0 = "tfl.broadcast_to"(%arg0, %arg1): (tensor<?x?x?x?x?x?xf32>, tensor<8xi32>) -> tensor<?x?x?x?x?x?x?x?xf32>
2321+
return %0 : tensor<?x?x?x?x?x?x?x?xf32>
2322+
}
2323+
2324+
// CHECK-LABEL: testBroadcastToWithI64ShapeTensor
2325+
func @testBroadcastToWithI64ShapeTensor(tensor<?x?x?x?x?x?xf32>, tensor<8xi64>) -> tensor<?x?x?x?x?x?x?x?xf32> {
2326+
^bb0(%arg0: tensor<?x?x?x?x?x?xf32>, %arg1: tensor<8xi64>):
2327+
// CHECK: "tfl.broadcast_to"(%arg0, %arg1)
2328+
%0 = "tfl.broadcast_to"(%arg0, %arg1): (tensor<?x?x?x?x?x?xf32>, tensor<8xi64>) -> tensor<?x?x?x?x?x?x?x?xf32>
2329+
return %0 : tensor<?x?x?x?x?x?x?x?xf32>
2330+
}

‎tensorflow/compiler/mlir/lite/tests/prepare-tf.mlir‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,70 @@ func @MatrixSetDiagV3Conversion(%arg0: tensor<3x3xi32>, %arg1: tensor<3xi32>) ->
578578
// CHECK: %[[RES:.*]] = "tf.MatrixSetDiag"(%arg0, %arg1) : (tensor<3x3xi32>, tensor<3xi32>) -> tensor<3x3xi32>
579579
// CHECK: return %[[RES]]
580580
}
581+
582+
func @broadcast_to_f32_low_dim(%arg0: tensor<3xf32>, %arg1: tensor<2xi32>) -> tensor<3x3xf32> {
583+
%0 = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<3xf32>, tensor<2xi32>) -> tensor<3x3xf32>
584+
return %0: tensor<3x3xf32>
585+
586+
// CHECK-LABEL: broadcast_to_f32_low_dim
587+
// CHECK: [[CST:%.*]] = constant dense<1.000000e+00> : tensor<3x3xf32>
588+
// CHECK: [[MUL:%.*]] = "tf.Mul"(%arg0, [[CST]]) : (tensor<3xf32>, tensor<3x3xf32>) -> tensor<3x3xf32>
589+
// CHECK: return [[MUL]] : tensor<3x3xf32>
590+
}
591+
592+
func @broadcast_to_i32_low_dim(%input: tensor<3xi32>, %shape: tensor<2xi32>) -> tensor<3x3xi32> {
593+
%0 = "tf.BroadcastTo"(%input, %shape) : (tensor<3xi32>, tensor<2xi32>) -> tensor<3x3xi32>
594+
return %0: tensor<3x3xi32>
595+
596+
// CHECK-LABEL: broadcast_to_i32_low_dim
597+
// CHECK: [[CST:%.*]] = constant dense<1> : tensor<3x3xi32>
598+
// CHECK: [[MUL:%.*]] = "tf.Mul"(%arg0, [[CST]]) : (tensor<3xi32>, tensor<3x3xi32>) -> tensor<3x3xi32>
599+
// CHECK: return [[MUL]] : tensor<3x3xi32>
600+
}
601+
602+
func @broadcast_to_low_dim_with_unknown_shape(%arg0: tensor<3xf32>, %arg1: tensor<*xi32>) -> tensor<3x3xf32> {
603+
%0 = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<3xf32>, tensor<*xi32>) -> tensor<3x3xf32>
604+
return %0: tensor<3x3xf32>
605+
606+
// CHECK-LABEL: broadcast_to_low_dim_with_unknown_shape
607+
// CHECK: [[CST:%.*]] = constant dense<1.000000e+00> : tensor<3x3xf32>
608+
// CHECK: [[MUL:%.*]] = "tf.Mul"(%arg0, [[CST]]) : (tensor<3xf32>, tensor<3x3xf32>) -> tensor<3x3xf32>
609+
// CHECK: return [[MUL]] : tensor<3x3xf32>
610+
}
611+
612+
func @broadcast_to_i32_low_dim_with_unknown_output(%input: tensor<3xi32>, %shape: tensor<2xi32>) -> tensor<*xi32> {
613+
%0 = "tf.BroadcastTo"(%input, %shape) : (tensor<3xi32>, tensor<2xi32>) -> tensor<*xi32>
614+
return %0: tensor<*xi32>
615+
616+
// CHECK-LABEL: broadcast_to_i32_low_dim_with_unknown_output
617+
// CHECK: [[CST:%.*]] = constant dense<1> : tensor<i32>
618+
// CHECK: [[FILL:%.*]] = "tf.Fill"(%arg1, [[CST]]) : (tensor<2xi32>, tensor<i32>) -> tensor<*xi32>
619+
// CHECK: [[MUL:%.*]] = "tf.Mul"(%arg0, [[FILL]]) : (tensor<3xi32>, tensor<*xi32>) -> tensor<*xi32>
620+
// CHECK: return [[MUL]] : tensor<*xi32>
621+
}
622+
623+
func @broadcast_to_high_dim_with_unknown_shape(%arg0: tensor<1x2x3x4x5x6xf32>, %arg1: tensor<*xi32>) -> tensor<7x8x1x2x3x4x5x6xf32> {
624+
%0 = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<1x2x3x4x5x6xf32>, tensor<*xi32>) -> tensor<7x8x1x2x3x4x5x6xf32>
625+
return %0: tensor<7x8x1x2x3x4x5x6xf32>
626+
627+
// CHECK-LABEL: broadcast_to_high_dim_with_unknown_shape
628+
// CHECK: [[BCT:%.*]] = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<1x2x3x4x5x6xf32>, tensor<*xi32>) -> tensor<7x8x1x2x3x4x5x6xf32>
629+
// CHECK: return [[BCT]] : tensor<7x8x1x2x3x4x5x6xf32>
630+
}
631+
632+
func @broadcast_to_high_dim_with_unknown_output(%arg0: tensor<1x2x3x4x5x6xf32>, %arg1: tensor<8xi32>) -> tensor<*xf32> {
633+
%0 = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<1x2x3x4x5x6xf32>, tensor<8xi32>) -> tensor<*xf32>
634+
return %0: tensor<*xf32>
635+
636+
// CHECK-LABEL: broadcast_to_high_dim_with_unknown_output
637+
// CHECK: [[BCT:%.*]] = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<1x2x3x4x5x6xf32>, tensor<8xi32>) -> tensor<*xf32>
638+
// CHECK: return [[BCT]] : tensor<*xf32>
639+
}
640+
641+
func @broadcast_to_with_unknown_shape_and_output(%arg0: tensor<1x2x3x4x5x6xf32>, %arg1: tensor<*xi32>) -> tensor<*xf32> {
642+
%0 = "tf.BroadcastTo"(%arg0, %arg1) : (tensor<1x2x3x4x5x6xf32>, tensor<*xi32>) -> tensor<*xf32>
643+
return %0: tensor<*xf32>
644+
645+
// CHECK-LABEL: broadcast_to_with_unknown_shape_and_output
646+
// CHECK: "tf.BroadcastTo"(%arg0, %arg1)
647+
}

‎tensorflow/compiler/mlir/lite/transforms/legalize_patterns.td‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def LegalizeArgMax : Pat<(TF_ArgMaxOp $input, $dim),
109109
def LegalizeArgMin : Pat<(TF_ArgMinOp $input, $dim),
110110
(TFL_ArgMinOp $input, $dim)>;
111111

112+
def LegalizeBroadcastTo : Pat<(TF_BroadcastToOp $input, $dim),
113+
(TFL_BroadcastToOp $input, $dim)>;
114+
112115
def LegalizeCeil : Pat<(TF_CeilOp $arg), (TFL_CeilOp $arg)>;
113116

114117
def LegalizeCos : Pat<(TF_CosOp $arg), (TFL_CosOp $arg)>;

‎tensorflow/compiler/mlir/lite/transforms/legalize_tf.cc‎

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ limitations under the License.
4545
#include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
4646
#include "tensorflow/compiler/mlir/lite/transforms/passes.h"
4747
#include "tensorflow/compiler/mlir/lite/utils/attribute_utils.h"
48+
#include "tensorflow/compiler/mlir/lite/utils/constant_utils.h"
4849
#include "tensorflow/compiler/mlir/lite/utils/validators.h"
4950
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
5051
#include "tensorflow/compiler/mlir/tensorflow/utils/mangling_util.h"
@@ -137,7 +138,6 @@ DECL_CONVERT_OP(StridedSlice);
137138
DECL_CONVERT_OP(Unpack);
138139
DECL_CONVERT_OP(Reciprocal);
139140
DECL_CONVERT_OP(RandomUniform);
140-
DECL_CONVERT_OP(BroadcastTo);
141141

142142
#undef DECL_CONVERT_OP
143143

@@ -483,89 +483,6 @@ LogicalResult ConvertTFAssertOp::matchAndRewrite(
483483
return success();
484484
}
485485

486-
StatusOr<ConstantOp> CreateConstOpWithSingleValue(PatternRewriter* rewriter,
487-
Location loc,
488-
ShapedType shaped_type,
489-
int value) {
490-
Type element_type = shaped_type.getElementType();
491-
ShapedType scalar_type = RankedTensorType::get({}, element_type);
492-
Attribute attr;
493-
switch (element_type.getKind()) {
494-
case mlir::StandardTypes::F16: {
495-
auto floatType = mlir::FloatType::getF16(element_type.getContext());
496-
auto floatAttr =
497-
mlir::FloatAttr::get(floatType, static_cast<float>(value));
498-
std::vector<Attribute> floatValues({floatAttr});
499-
attr = DenseElementsAttr::get(scalar_type, floatValues);
500-
break;
501-
}
502-
case mlir::StandardTypes::BF16: {
503-
auto floatType = mlir::FloatType::getBF16(element_type.getContext());
504-
auto floatAttr =
505-
mlir::FloatAttr::get(floatType, static_cast<float>(value));
506-
std::vector<Attribute> floatValues({floatAttr});
507-
attr = DenseElementsAttr::get(scalar_type, floatValues);
508-
break;
509-
}
510-
case mlir::StandardTypes::F32: {
511-
attr =
512-
DenseElementsAttr::get<float>(scalar_type, static_cast<float>(value));
513-
break;
514-
}
515-
case mlir::StandardTypes::Complex: {
516-
auto etype = element_type.cast<mlir::ComplexType>().getElementType();
517-
if (etype.isF32()) {
518-
auto dialect = etype.getContext()->getRegisteredDialect("tf");
519-
tensorflow::TensorProto repr;
520-
repr.set_dtype(tensorflow::DT_COMPLEX64);
521-
522-
tensorflow::TensorShapeProto* shape = repr.mutable_tensor_shape();
523-
shape->set_unknown_rank(false);
524-
shape->add_dim()->set_size(int64_t{1});
525-
std::string content;
526-
auto complex_value =
527-
std::complex<float>(static_cast<float>(value), 0.0f);
528-
content.assign(reinterpret_cast<const char*>(&complex_value),
529-
sizeof(complex_value));
530-
repr.set_tensor_content(content);
531-
std::string mangled = tensorflow::mangling_util::MangleTensor(repr);
532-
533-
attr = mlir::OpaqueElementsAttr::get(dialect, scalar_type, mangled);
534-
break;
535-
}
536-
return Status(tensorflow::error::INVALID_ARGUMENT, "Unsupported type");
537-
}
538-
case mlir::StandardTypes::Integer: {
539-
const auto& itype = element_type.cast<mlir::IntegerType>();
540-
switch (itype.getWidth()) {
541-
case 8:
542-
attr = DenseElementsAttr::get<int8_t>(scalar_type,
543-
static_cast<int8_t>(value));
544-
break;
545-
case 16:
546-
attr = DenseElementsAttr::get<int16_t>(scalar_type,
547-
static_cast<int16_t>(value));
548-
break;
549-
case 32:
550-
attr = DenseElementsAttr::get<int32_t>(scalar_type,
551-
static_cast<int32_t>(value));
552-
break;
553-
case 64:
554-
attr = DenseElementsAttr::get<int64_t>(scalar_type,
555-
static_cast<int64_t>(value));
556-
break;
557-
default:
558-
return Status(tensorflow::error::INVALID_ARGUMENT,
559-
"Unsupported type");
560-
}
561-
break;
562-
}
563-
default:
564-
return Status(tensorflow::error::INVALID_ARGUMENT, "Unsupported type");
565-
}
566-
return rewriter->create<ConstantOp>(loc, scalar_type, attr);
567-
}
568-
569486
LogicalResult ConvertTFReciprocalOp::matchAndRewrite(
570487
Operation* op, PatternRewriter& rewriter) const {
571488
auto tf_reciprocal_op = cast<TF::ReciprocalOp>(op);
@@ -586,31 +503,6 @@ LogicalResult ConvertTFReciprocalOp::matchAndRewrite(
586503
return success();
587504
}
588505

589-
LogicalResult ConvertTFBroadcastToOp::matchAndRewrite(
590-
Operation* op, PatternRewriter& rewriter) const {
591-
auto tf_broadcast_to_op = cast<TF::BroadcastToOp>(op);
592-
auto element_type = tf_broadcast_to_op.input().getType().cast<ShapedType>();
593-
auto output_type = tf_broadcast_to_op.output().getType();
594-
595-
auto status_or_const_op =
596-
CreateConstOpWithSingleValue(&rewriter, op->getLoc(), element_type, 1);
597-
if (!status_or_const_op.ok()) {
598-
return failure();
599-
}
600-
601-
auto tfl_fill_op = rewriter.create<TFL::FillOp>(
602-
op->getLoc(), output_type, tf_broadcast_to_op.shape(),
603-
status_or_const_op.ValueOrDie());
604-
605-
StringAttr fused_activation_function =
606-
StringAttr::get("NONE", rewriter.getContext());
607-
608-
rewriter.replaceOpWithNewOp<TFL::MulOp>(
609-
op, output_type, tf_broadcast_to_op.input(), tfl_fill_op,
610-
fused_activation_function);
611-
return success();
612-
}
613-
614506
// Legalize unidirectional sequence lstm.
615507
struct LegalizeUnidirectionalSequenceLstm : public RewritePattern {
616508
explicit LegalizeUnidirectionalSequenceLstm(MLIRContext* context)
@@ -751,7 +643,7 @@ void LegalizeTF::runOnFunction() {
751643
ConvertTFMatrixDiagV3Op, ConvertTFPackOp, ConvertTFReshapeOp,
752644
ConvertTFSplitOp, ConvertTFSplitVOp, ConvertTFStridedSliceOp,
753645
ConvertTFUnpackOp, ConvertTFAssertOp, ConvertTFReciprocalOp,
754-
ConvertTFRandomUniformOp, ConvertTFBroadcastToOp>(context);
646+
ConvertTFRandomUniformOp>(context);
755647

756648
// Ophint python converter converted tf node pattern.
757649
patterns.insert<LegalizeUnidirectionalSequenceLstm,

0 commit comments

Comments
 (0)