diff --git a/tensorflow/compiler/mlir/lite/tests/prepare-tf.mlir b/tensorflow/compiler/mlir/lite/tests/prepare-tf.mlir index 186c8631e56f79f477ce5f6e4ea0f1bc56c41443..88de48cf1f9f1dd89fc48ed2b7431ffe7f72a60a 100644 --- a/tensorflow/compiler/mlir/lite/tests/prepare-tf.mlir +++ b/tensorflow/compiler/mlir/lite/tests/prepare-tf.mlir @@ -639,4 +639,11 @@ func @DontMatchFusedBatchNormV3(%arg0 :tensor, %arg1 : tensor<576 // CHECK: "tf.FusedBatchNormV3" } +// CHECK-LABEL: DoNotConvertConv2DWhenFilterTypeDimIsNotDecided +func @DoNotConvertConv2DWhenFilterTypeDimIsNotDecided(%arg0 : tensor, %arg1 : tensor<3x3x96x?xf32>) -> tensor { + %0 = "tf.Conv2D"(%arg0, %arg1) {data_format = "NHWC", device = "", dilations = [1, 1, 1, 1], explicit_paddings = [], padding = "SAME", strides = [1, 1, 1, 1], use_cudnn_on_gpu = true} : (tensor, tensor<3x3x96x?xf32>) -> tensor + return %0 : tensor +// CHECK: tf.Conv2D +} + } diff --git a/tensorflow/compiler/mlir/lite/transforms/prepare_tf.cc b/tensorflow/compiler/mlir/lite/transforms/prepare_tf.cc index ef1276595043cdd390e45ffb6e41a3676234e8cc..3fb5c2cc6f7c1a523569ff1f164d915ab61ce556 100644 --- a/tensorflow/compiler/mlir/lite/transforms/prepare_tf.cc +++ b/tensorflow/compiler/mlir/lite/transforms/prepare_tf.cc @@ -328,7 +328,9 @@ struct ConvertTFConvOp : public RewritePattern { // tensor, for setting depth_multiplier attribute, etc.). auto filter = tf_op.filter(); auto filter_type = filter.getType().template dyn_cast(); - if (!filter_type || filter_type.getRank() != 4) return failure(); + if (!filter_type || filter_type.getRank() != 4 || + !filter_type.hasStaticShape()) + return failure(); // TensorFlow convolution op only has two inputs, while the TFLite one has // three, with the bias vector marked as optional. However, TOCO has a