From 91eeb068b1f2709784aba37ec32bb867351bc2be Mon Sep 17 00:00:00 2001 From: Nupur Garg Date: Thu, 22 Aug 2019 14:29:25 -0700 Subject: [PATCH] Remove if_mlir_tflite build flag. PiperOrigin-RevId: 264920065 --- tensorflow/lite/toco/python/BUILD | 12 +++--------- tensorflow/lite/toco/python/toco_python_api.cc | 15 +-------------- tensorflow/tensorflow.bzl | 4 ---- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/tensorflow/lite/toco/python/BUILD b/tensorflow/lite/toco/python/BUILD index 79357f66676..f2dbc742e34 100644 --- a/tensorflow/lite/toco/python/BUILD +++ b/tensorflow/lite/toco/python/BUILD @@ -1,5 +1,5 @@ load("//tensorflow:tensorflow.bzl", "tf_py_wrap_cc") -load("//tensorflow:tensorflow.bzl", "if_mlir_tflite", "py_binary", "tf_py_test") +load("//tensorflow:tensorflow.bzl", "py_binary", "tf_py_test") package( default_visibility = [ @@ -22,10 +22,6 @@ cc_library( name = "toco_python_api", srcs = ["toco_python_api.cc"], hdrs = ["toco_python_api.h"], - defines = if_mlir_tflite( - if_false = [], - if_true = ["TFLITE_BUILD_WITH_MLIR_CONVERTER"], - ), visibility = [ "//tensorflow/python:__subpackages__", ], @@ -39,6 +35,7 @@ cc_library( "//tensorflow/lite/toco:toco_port", "//tensorflow/lite/toco:toco_tooling", "//tensorflow/core:protos_all_cc", + "//tensorflow/compiler/mlir/lite/python:graphdef_to_tfl_flatbuffer", ] + select({ # This is required when running `tflite_convert` from `bazel`. # It requires to link with TensorFlow Ops to get the op definitions. @@ -46,10 +43,7 @@ cc_library( "//tensorflow/core:ops", ], "//conditions:default": [], - }) + if_mlir_tflite( - if_false = [], - if_true = ["//tensorflow/compiler/mlir/lite/python:graphdef_to_tfl_flatbuffer"], - ), + }), ) # Compatibility stub. Remove when internal customers moved. diff --git a/tensorflow/lite/toco/python/toco_python_api.cc b/tensorflow/lite/toco/python/toco_python_api.cc index bb86f12c01d..5590fad609f 100644 --- a/tensorflow/lite/toco/python/toco_python_api.cc +++ b/tensorflow/lite/toco/python/toco_python_api.cc @@ -18,6 +18,7 @@ limitations under the License. #include #include +#include "tensorflow/compiler/mlir/lite/python/graphdef_to_tfl_flatbuffer.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/lite/python/interpreter_wrapper/python_utils.h" #include "tensorflow/lite/toco/import_tensorflow.h" @@ -28,11 +29,6 @@ limitations under the License. #include "tensorflow/lite/toco/toco_tooling.h" #include "tensorflow/lite/toco/toco_types.h" -#if defined(TFLITE_BUILD_WITH_MLIR_CONVERTER) -#include "tensorflow/compiler/mlir/lite/python/graphdef_to_tfl_flatbuffer.h" -#endif -#include "tensorflow/core/protobuf/graph_debug_info.pb.h" - namespace toco { // NOTE(aselle): We are using raw PyObject's here because we want to make @@ -124,18 +120,9 @@ PyObject* TocoConvert(PyObject* model_flags_proto_txt_raw, // Convert model. if (enable_mlir_converter) { -#if defined(TFLITE_BUILD_WITH_MLIR_CONVERTER) status = tensorflow::ConvertGraphDefToTFLiteFlatBuffer( model_flags, toco_flags, debug_info, graph_def, &output_file_contents_txt); -#else - // TODO(b/124314620): Remove this condition. - PyErr_SetString(PyExc_RuntimeError, - "This flag is not supported by this version of the " - "TFLite converter. This functionality is being " - "actively worked on."); - return nullptr; -#endif } else { model = toco::Import(toco_flags, model_flags, input_contents_txt); toco::Transform(toco_flags, model.get()); diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 705e62541a7..ff1dd637aad 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -2556,9 +2556,5 @@ def if_mlir(if_true, if_false = []): "//tensorflow:with_mlir_support": if_true, }) -# TODO(b/138724071): Remove when build is stable. -def if_mlir_tflite(if_true, if_false = []): - return if_true # Internally we always build with MLIR. - def tfcompile_extra_flags(): return ""