diff --git a/tensorflow/lite/BUILD b/tensorflow/lite/BUILD index 0e1c26b628b..76e9f5de7c1 100644 --- a/tensorflow/lite/BUILD +++ b/tensorflow/lite/BUILD @@ -1,5 +1,5 @@ load("//tensorflow:tensorflow.bzl", "if_not_windows", "tf_cc_test") -load("//tensorflow/lite:build_def.bzl", "if_tflite_experimental_runtime", "tflite_cc_shared_object", "tflite_copts", "tflite_experimental_runtime_linkopts") +load("//tensorflow/lite:build_def.bzl", "tflite_cc_shared_object", "tflite_copts") load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite") load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable") @@ -37,18 +37,6 @@ config_setting( }, ) -config_setting( - name = "tflite_experimental_runtime_eager", - values = {"define": "tflite_experimental_runtime=eager"}, - visibility = ["//visibility:public"], -) - -config_setting( - name = "tflite_experimental_runtime_non_eager", - values = {"define": "tflite_experimental_runtime=non-eager"}, - visibility = ["//visibility:public"], -) - config_setting( name = "tf_lite_static_memory", values = { @@ -283,16 +271,11 @@ cc_library( hdrs = FRAMEWORK_LIB_HDRS, compatible_with = get_compatible_with_portable(), copts = tflite_copts() + TFLITE_DEFAULT_COPTS, - defines = if_tflite_experimental_runtime( - if_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_EAGER"], - if_non_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER"], - if_none = [], - ), deps = [ - ":framework_lib", ":allocation", ":arena_planner", ":external_cpu_backend_context", + ":framework_lib", ":graph_info", ":memory_planner", ":minimal_logging", @@ -307,7 +290,7 @@ cc_library( "//tensorflow/lite/experimental/resource", "//tensorflow/lite/nnapi:nnapi_implementation", "//tensorflow/lite/schema:schema_fbs", - ] + tflite_experimental_runtime_linkopts(), + ], ) cc_library( diff --git a/tensorflow/lite/build_def.bzl b/tensorflow/lite/build_def.bzl index bdddac82d5b..57c04be11f0 100644 --- a/tensorflow/lite/build_def.bzl +++ b/tensorflow/lite/build_def.bzl @@ -742,27 +742,6 @@ def gen_model_coverage_test(src, model_name, data, failure_type, tags, size = "m ] + flex_dep(target_op_sets), ) -def if_tflite_experimental_runtime(if_eager, if_non_eager, if_none = []): - return select({ - "//tensorflow/lite:tflite_experimental_runtime_eager": if_eager, - "//tensorflow/lite:tflite_experimental_runtime_non_eager": if_non_eager, - "//conditions:default": if_none, - }) - -def tflite_experimental_runtime_linkopts(if_eager = [], if_non_eager = [], if_none = []): - return if_tflite_experimental_runtime( - if_eager = [ - # "//tensorflow/lite/experimental/tf_runtime:eager_interpreter", - # "//tensorflow/lite/experimental/tf_runtime:eager_model", - # "//tensorflow/lite/experimental/tf_runtime:subgraph", - ] + if_eager, - if_non_eager = [ - # "//tensorflow/lite/experimental/tf_runtime:interpreter", - # "//tensorflow/lite/experimental/tf_runtime:model", - ] + if_non_eager, - if_none = [] + if_none, - ) - def tflite_custom_cc_library( name, models = [], diff --git a/tensorflow/lite/core/subgraph.cc b/tensorflow/lite/core/subgraph.cc index c742552f418..2fe8099d372 100644 --- a/tensorflow/lite/core/subgraph.cc +++ b/tensorflow/lite/core/subgraph.cc @@ -30,8 +30,6 @@ limitations under the License. namespace tflite { -namespace impl { - namespace { struct TfLiteQuantizationDeleter { @@ -1517,6 +1515,4 @@ TfLiteStatus Subgraph::SetCustomAllocationForTensor( return kTfLiteOk; } -} // namespace impl - } // namespace tflite diff --git a/tensorflow/lite/core/subgraph.h b/tensorflow/lite/core/subgraph.h index 4e40d20546a..c74611a6ca4 100644 --- a/tensorflow/lite/core/subgraph.h +++ b/tensorflow/lite/core/subgraph.h @@ -30,14 +30,8 @@ limitations under the License. #include "tensorflow/lite/memory_planner.h" #include "tensorflow/lite/util.h" -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -#include "tensorflow/lite/experimental/tf_runtime/public/subgraph.h" -#endif - namespace tflite { -namespace impl { - // Forward declare since NNAPIDelegate uses Interpreter. class NNAPIDelegate; @@ -739,13 +733,5 @@ class Subgraph { resource::ResourceMap* resources_ = nullptr; }; -} // namespace impl - -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -using Subgraph = tflrt::Subgraph; -#else -using Subgraph = impl::Subgraph; -#endif - } // namespace tflite #endif // TENSORFLOW_LITE_CORE_SUBGRAPH_H_ diff --git a/tensorflow/lite/delegates/interpreter_utils.h b/tensorflow/lite/delegates/interpreter_utils.h index f736c2db1f4..fa55046f01f 100644 --- a/tensorflow/lite/delegates/interpreter_utils.h +++ b/tensorflow/lite/delegates/interpreter_utils.h @@ -22,7 +22,6 @@ limitations under the License. namespace tflite { namespace delegates { -#if !TFLITE_EXPERIMENTAL_RUNTIME_EAGER class InterpreterUtils { public: /// Invokes an interpreter with automatic fallback from delegation to CPU. @@ -45,7 +44,6 @@ class InterpreterUtils { /// WARNING: This is an experimental API and subject to change. static TfLiteStatus InvokeWithCPUFallback(Interpreter* interpreter); }; -#endif // !TFLITE_EXPERIMENTAL_RUNTIME_EAGER } // namespace delegates } // namespace tflite diff --git a/tensorflow/lite/experimental/tflite_api_dispatcher/BUILD b/tensorflow/lite/experimental/tflite_api_dispatcher/BUILD index f4ade28eab8..fff0a47c323 100644 --- a/tensorflow/lite/experimental/tflite_api_dispatcher/BUILD +++ b/tensorflow/lite/experimental/tflite_api_dispatcher/BUILD @@ -1,5 +1,3 @@ -load("//tensorflow/lite:build_def.bzl", "if_tflite_experimental_runtime", "tflite_experimental_runtime_linkopts") - package( default_visibility = ["//tensorflow:internal"], licenses = ["notice"], # Apache 2.0 @@ -8,14 +6,9 @@ package( cc_library( name = "tflite_api_dispatcher", hdrs = ["tflite_api_dispatcher.h"], - defines = if_tflite_experimental_runtime( - if_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_EAGER"], - if_non_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER"], - if_none = [], - ), deps = [ "//tensorflow/lite:framework_lib", - ] + tflite_experimental_runtime_linkopts(), + ], ) cc_library( @@ -24,14 +17,5 @@ cc_library( deps = [ ":tflite_api_dispatcher", "//tensorflow/lite:framework_lib", - ] + tflite_experimental_runtime_linkopts( - if_eager = [ - # "//tensorflow/lite/experimental/tf_runtime/opdef:tflrt_opdefs", - # "//tensorflow/lite/experimental/tf_runtime/tfrt_ops:tfrt_tflite_ops_alwayslink", - ], - if_non_eager = [ - # "//tensorflow/lite/experimental/tf_runtime/tfrt_kernels:tfrt_tflite_interpreter_alwayslink", - # "//third_party/tf_runtime:basic_kernels_alwayslink", - ], - ), + ], ) diff --git a/tensorflow/lite/experimental/tflite_api_dispatcher/tflite_api_dispatcher.h b/tensorflow/lite/experimental/tflite_api_dispatcher/tflite_api_dispatcher.h index ab822d6ae7b..ecb90b48c50 100644 --- a/tensorflow/lite/experimental/tflite_api_dispatcher/tflite_api_dispatcher.h +++ b/tensorflow/lite/experimental/tflite_api_dispatcher/tflite_api_dispatcher.h @@ -18,25 +18,12 @@ limitations under the License. #ifndef TENSORFLOW_LITE_EXPERIMENTAL_TFLITE_API_DISPATCHER_TFLITE_API_DISPATCHER_H_ #define TENSORFLOW_LITE_EXPERIMENTAL_TFLITE_API_DISPATCHER_TFLITE_API_DISPATCHER_H_ -#ifndef TFLITE_EXPERIMENTAL_RUNTIME_EAGER -#define TFLITE_EXPERIMENTAL_RUNTIME_EAGER (0) -#endif - -#ifndef TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER -#define TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER (0) -#endif - -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER && TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER -#error \ - "TFLITE_EXPERIMENTAL_RUNTIME_EAGER and " \ - "TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER should not both be true." +#ifndef TFLITE_EXPERIMENTAL_RUNTIME +#define TFLITE_EXPERIMENTAL_RUNTIME (0) #endif // Import the relevant interpreter and model files. -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -#include "tensorflow/lite/experimental/tf_runtime/lib/eager_model.h" -#include "tensorflow/lite/experimental/tf_runtime/public/eager_interpreter.h" -#elif TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER +#if TFLITE_EXPERIMENTAL_RUNTIME #include "tensorflow/lite/experimental/tf_runtime/lib/model.h" #include "tensorflow/lite/experimental/tf_runtime/public/interpreter.h" #else @@ -47,12 +34,7 @@ limitations under the License. namespace tflite_api_dispatcher { // Use the correct interpreter. -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -using Interpreter = tflrt::EagerInterpreter; -using InterpreterBuilder = tflrt::EagerTfLiteInterpreterBuilderAPI; -using TfLiteModel = tflite::FlatBufferModel; -using TfLiteVerifier = tflite::TfLiteVerifier; -#elif TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER +#if TFLITE_EXPERIMENTAL_RUNTIME using Interpreter = tflrt::TfLiteInterpreterAPI; using InterpreterBuilder = tflrt::TfLiteInterpreterBuilderAPI; using TfLiteModel = tflrt::BEFModel; diff --git a/tensorflow/lite/interpreter.cc b/tensorflow/lite/interpreter.cc index a79ea86f61e..25acac96cf4 100644 --- a/tensorflow/lite/interpreter.cc +++ b/tensorflow/lite/interpreter.cc @@ -52,8 +52,6 @@ static_assert(sizeof(TfLiteFloat16) == sizeof(uint16_t), namespace tflite { -namespace impl { - namespace { // Gets the current TfLiteQuantization from the legacy TfLiteQuantizationParams. @@ -475,6 +473,4 @@ Profiler* Interpreter::GetProfiler() { return primary_subgraph().GetProfiler(); } -} // namespace impl - } // namespace tflite diff --git a/tensorflow/lite/interpreter.h b/tensorflow/lite/interpreter.h index 4561e138e72..77253ca836d 100644 --- a/tensorflow/lite/interpreter.h +++ b/tensorflow/lite/interpreter.h @@ -36,10 +36,6 @@ limitations under the License. #include "tensorflow/lite/stderr_reporter.h" #include "tensorflow/lite/type_to_tflitetype.h" -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -#include "tensorflow/lite/experimental/tf_runtime/public/eager_interpreter.h" -#endif - namespace tflite { class InterpreterTest; @@ -48,8 +44,6 @@ namespace delegates { class InterpreterUtils; // Class for friend declarations. } // namespace delegates -namespace impl { - /// An interpreter for a graph of nodes that input and output from tensors. /// Each node of the graph processes a set of input tensors and produces a /// set of output Tensors. All inputs/output tensors are referenced by index. @@ -659,13 +653,5 @@ class Interpreter { std::vector<TfLiteDelegatePtr> lazy_delegate_providers_; }; -} // namespace impl - -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -using Interpreter = tflrt::EagerInterpreter; -#else -using Interpreter = impl::Interpreter; -#endif - } // namespace tflite #endif // TENSORFLOW_LITE_INTERPRETER_H_ diff --git a/tensorflow/lite/interpreter_builder.cc b/tensorflow/lite/interpreter_builder.cc index 7743bc732fb..6c2b2e24558 100644 --- a/tensorflow/lite/interpreter_builder.cc +++ b/tensorflow/lite/interpreter_builder.cc @@ -137,8 +137,6 @@ TFLITE_ATTRIBUTE_WEAK Interpreter::TfLiteDelegatePtr AcquireFlexDelegate() { return Interpreter::TfLiteDelegatePtr(nullptr, [](TfLiteDelegate*) {}); } -namespace impl { - InterpreterBuilder::InterpreterBuilder(const FlatBufferModel& model, const OpResolver& op_resolver) : model_(model.GetModel()), @@ -679,6 +677,4 @@ TfLiteStatus InterpreterBuilder::operator()( return kTfLiteOk; } -} // namespace impl - } // namespace tflite diff --git a/tensorflow/lite/interpreter_builder.h b/tensorflow/lite/interpreter_builder.h index aac35f9e48a..4b0052f66ce 100644 --- a/tensorflow/lite/interpreter_builder.h +++ b/tensorflow/lite/interpreter_builder.h @@ -30,8 +30,6 @@ limitations under the License. namespace tflite { -namespace impl { - /// Build an interpreter capable of interpreting `model`. /// /// `model`: A model whose lifetime must be at least as long as any @@ -96,8 +94,6 @@ class InterpreterBuilder { int num_fp32_tensors_ = 0; }; -} // namespace impl - } // namespace tflite #endif // TENSORFLOW_LITE_INTERPRETER_BUILDER_H_ diff --git a/tensorflow/lite/model.h b/tensorflow/lite/model.h index 079b4ad2a40..39c7fd77c16 100644 --- a/tensorflow/lite/model.h +++ b/tensorflow/lite/model.h @@ -18,23 +18,9 @@ limitations under the License. #ifndef TENSORFLOW_LITE_MODEL_H_ #define TENSORFLOW_LITE_MODEL_H_ +#include "tensorflow/lite/interpreter_builder.h" #include "tensorflow/lite/model_builder.h" -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -#include "tensorflow/lite/experimental/tf_runtime/lib/eager_model.h" -#else -#include "tensorflow/lite/interpreter_builder.h" -#endif - -namespace tflite { - -#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER -using InterpreterBuilder = tflrt::EagerTfLiteInterpreterBuilderAPI; -using Interpreter = tflrt::EagerInterpreter; -#else -using InterpreterBuilder = impl::InterpreterBuilder; -#endif - -} // namespace tflite +// TODO(b/168725050): Address the issue of proxy header in this file. #endif // TENSORFLOW_LITE_MODEL_H_