From 1059951b8e7445c9a8e09433fd22b885da35f3e3 Mon Sep 17 00:00:00 2001 From: Haoliang Zhang Date: Tue, 9 Jul 2019 12:08:22 -0700 Subject: [PATCH] Add dynamic_rnn into MLIR generated_examples test. PiperOrigin-RevId: 257243999 --- .../compiler/mlir/lite/tf_to_tfl_flatbuffer.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.cc b/tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.cc index 759f93c94a3..647f1d75d7b 100644 --- a/tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.cc +++ b/tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.cc @@ -100,6 +100,16 @@ void AddTFToTFLConversionPasses(bool emit_builtin_tflite_ops, bool run_quantize, bool lower_tensor_list_ops, mlir::PassManager *pass_manager) { pass_manager->addPass(mlir::TFControlFlow::CreateRaiseTFControlFlowPass()); + + if (lower_tensor_list_ops) { + // Execute this pass before `CanonicalizerPass` in case some TensorList + // ops are constant folded into variant types. + // TODO(haoliang): Add this pass by default. + // TODO(b/137038401): Handle other ops that operate on variant types and + // improve error reporting. + pass_manager->addPass(mlir::TFL::CreateLowerStaticTensorListPass()); + } + // TODO(jpienaar): Revise post dialect constants. pass_manager->addPass(mlir::TF::CreateDecodeConstantPass()); // Canonicalization includes const folding, which is utilized here to optimize @@ -112,10 +122,6 @@ void AddTFToTFLConversionPasses(bool emit_builtin_tflite_ops, bool run_quantize, if (emit_builtin_tflite_ops) { // Prepare for TFLite dialect, rerun canonicalization, and then legalize to // the TFLite dialect. - // TODO(haoliang): Add this pass by default. - if (lower_tensor_list_ops) { - pass_manager->addPass(mlir::TFL::CreateLowerStaticTensorListPass()); - } pass_manager->addPass(mlir::TFL::CreatePrepareTFPass()); pass_manager->addPass(mlir::createCanonicalizerPass()); pass_manager->addPass(mlir::TFL::CreateLegalizeTFPass());