From 869920697b243622073317ddc533bdff41684c41 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Mon, 18 May 2020 13:27:55 -0700 Subject: [PATCH] [tf.lite] Use in-process conversion when the new converter is used Out-of-process conversion was a workaround for the legacy converter, which would generally crash the process when conversion failed. However, out-of-process conversion also adds a good deal of complexity, so avoid it when using the new conversion backend. PiperOrigin-RevId: 312142994 Change-Id: I7ddc83df99ccf24be6e15f46d6a116dce8321933 --- tensorflow/lite/python/convert.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/python/convert.py b/tensorflow/lite/python/convert.py index 6b7a32f1bcc..a5fbb88132e 100644 --- a/tensorflow/lite/python/convert.py +++ b/tensorflow/lite/python/convert.py @@ -169,9 +169,10 @@ def toco_convert_protos(model_flags_str, RuntimeError: When conversion fails, an exception is raised with the error message embedded. """ - # TODO(aselle): When toco does not use fatal errors for failure, we can - # switch this on. - if not _toco_from_proto_bin: + # Historically, TOCO conversion failures would trigger a crash, so we would + # attempt to run the converter out-of-process. The MLIR conversion pipeline + # surfaces errors instead, and can be safely run in-process. + if enable_mlir_converter or not _toco_from_proto_bin: try: model_str = wrap_toco.wrapped_toco_convert(model_flags_str, toco_flags_str, input_data_str,