Internal change

PiperOrigin-RevId: 332364434
Change-Id: I91a2e0e7fcd09c0aa5e7cdbf07c06bfac3599c7b
This commit is contained in:
A. Unique TensorFlower 2020-09-17 19:08:27 -07:00 committed by TensorFlower Gardener
parent b1c97a0bb2
commit 294ef77385
12 changed files with 11 additions and 143 deletions

View File

@ -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(

View File

@ -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 = [],

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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",
],
),
],
)

View File

@ -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;

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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_

View File

@ -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_