From 02032fb477e9417197132648ec81e75beee9063a Mon Sep 17 00:00:00 2001 From: Karim Nosir Date: Tue, 22 Dec 2020 00:25:59 -0800 Subject: [PATCH] Always enable TF2 in tflite_convert command line tool. If user needs to use TF1 converter then they can pass --enable_v1_converter. Before this users needed to set environment variable TF2_BEHAVIOR=1 before invoking the tool to use v2 converter. PiperOrigin-RevId: 348591322 Change-Id: I25baf70c2bafa56a63ac9c629ad563e26a062d86 --- tensorflow/lite/python/BUILD | 2 ++ tensorflow/lite/python/tflite_convert.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tensorflow/lite/python/BUILD b/tensorflow/lite/python/BUILD index cd7ad528247..5bb0b0328ad 100644 --- a/tensorflow/lite/python/BUILD +++ b/tensorflow/lite/python/BUILD @@ -62,6 +62,7 @@ py_binary( visibility = ["//visibility:public"], deps = [ ":tflite_convert_main_lib", + "//tensorflow:tensorflow_py", "@six_archive//:six", ], ) @@ -73,6 +74,7 @@ py_library( visibility = ["//visibility:public"], deps = [ ":tflite_convert_lib", + "//tensorflow:tensorflow_py", "@six_archive//:six", ], ) diff --git a/tensorflow/lite/python/tflite_convert.py b/tensorflow/lite/python/tflite_convert.py index 49275a793bc..0833e2b26c5 100644 --- a/tensorflow/lite/python/tflite_convert.py +++ b/tensorflow/lite/python/tflite_convert.py @@ -26,6 +26,8 @@ import warnings import six from six.moves import zip +# Needed to enable TF2 by default. +import tensorflow as tf # pylint: disable=unused-import from tensorflow.lite.python import lite from tensorflow.lite.python.convert import register_custom_opdefs