Internal change
PiperOrigin-RevId: 332364434 Change-Id: I91a2e0e7fcd09c0aa5e7cdbf07c06bfac3599c7b
This commit is contained in:
parent
b1c97a0bb2
commit
294ef77385
@ -1,5 +1,5 @@
|
|||||||
load("//tensorflow:tensorflow.bzl", "if_not_windows", "tf_cc_test")
|
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/lite:special_rules.bzl", "tflite_portable_test_suite")
|
||||||
load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable")
|
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(
|
config_setting(
|
||||||
name = "tf_lite_static_memory",
|
name = "tf_lite_static_memory",
|
||||||
values = {
|
values = {
|
||||||
@ -283,16 +271,11 @@ cc_library(
|
|||||||
hdrs = FRAMEWORK_LIB_HDRS,
|
hdrs = FRAMEWORK_LIB_HDRS,
|
||||||
compatible_with = get_compatible_with_portable(),
|
compatible_with = get_compatible_with_portable(),
|
||||||
copts = tflite_copts() + TFLITE_DEFAULT_COPTS,
|
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 = [
|
deps = [
|
||||||
":framework_lib",
|
|
||||||
":allocation",
|
":allocation",
|
||||||
":arena_planner",
|
":arena_planner",
|
||||||
":external_cpu_backend_context",
|
":external_cpu_backend_context",
|
||||||
|
":framework_lib",
|
||||||
":graph_info",
|
":graph_info",
|
||||||
":memory_planner",
|
":memory_planner",
|
||||||
":minimal_logging",
|
":minimal_logging",
|
||||||
@ -307,7 +290,7 @@ cc_library(
|
|||||||
"//tensorflow/lite/experimental/resource",
|
"//tensorflow/lite/experimental/resource",
|
||||||
"//tensorflow/lite/nnapi:nnapi_implementation",
|
"//tensorflow/lite/nnapi:nnapi_implementation",
|
||||||
"//tensorflow/lite/schema:schema_fbs",
|
"//tensorflow/lite/schema:schema_fbs",
|
||||||
] + tflite_experimental_runtime_linkopts(),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
@ -742,27 +742,6 @@ def gen_model_coverage_test(src, model_name, data, failure_type, tags, size = "m
|
|||||||
] + flex_dep(target_op_sets),
|
] + 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(
|
def tflite_custom_cc_library(
|
||||||
name,
|
name,
|
||||||
models = [],
|
models = [],
|
||||||
|
@ -30,8 +30,6 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TfLiteQuantizationDeleter {
|
struct TfLiteQuantizationDeleter {
|
||||||
@ -1517,6 +1515,4 @@ TfLiteStatus Subgraph::SetCustomAllocationForTensor(
|
|||||||
return kTfLiteOk;
|
return kTfLiteOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
@ -30,14 +30,8 @@ limitations under the License.
|
|||||||
#include "tensorflow/lite/memory_planner.h"
|
#include "tensorflow/lite/memory_planner.h"
|
||||||
#include "tensorflow/lite/util.h"
|
#include "tensorflow/lite/util.h"
|
||||||
|
|
||||||
#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
|
||||||
#include "tensorflow/lite/experimental/tf_runtime/public/subgraph.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
// Forward declare since NNAPIDelegate uses Interpreter.
|
// Forward declare since NNAPIDelegate uses Interpreter.
|
||||||
class NNAPIDelegate;
|
class NNAPIDelegate;
|
||||||
|
|
||||||
@ -739,13 +733,5 @@ class Subgraph {
|
|||||||
resource::ResourceMap* resources_ = nullptr;
|
resource::ResourceMap* resources_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
|
||||||
using Subgraph = tflrt::Subgraph;
|
|
||||||
#else
|
|
||||||
using Subgraph = impl::Subgraph;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
#endif // TENSORFLOW_LITE_CORE_SUBGRAPH_H_
|
#endif // TENSORFLOW_LITE_CORE_SUBGRAPH_H_
|
||||||
|
@ -22,7 +22,6 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
namespace delegates {
|
namespace delegates {
|
||||||
#if !TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
|
||||||
class InterpreterUtils {
|
class InterpreterUtils {
|
||||||
public:
|
public:
|
||||||
/// Invokes an interpreter with automatic fallback from delegation to CPU.
|
/// 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.
|
/// WARNING: This is an experimental API and subject to change.
|
||||||
static TfLiteStatus InvokeWithCPUFallback(Interpreter* interpreter);
|
static TfLiteStatus InvokeWithCPUFallback(Interpreter* interpreter);
|
||||||
};
|
};
|
||||||
#endif // !TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
|
||||||
} // namespace delegates
|
} // namespace delegates
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
load("//tensorflow/lite:build_def.bzl", "if_tflite_experimental_runtime", "tflite_experimental_runtime_linkopts")
|
|
||||||
|
|
||||||
package(
|
package(
|
||||||
default_visibility = ["//tensorflow:internal"],
|
default_visibility = ["//tensorflow:internal"],
|
||||||
licenses = ["notice"], # Apache 2.0
|
licenses = ["notice"], # Apache 2.0
|
||||||
@ -8,14 +6,9 @@ package(
|
|||||||
cc_library(
|
cc_library(
|
||||||
name = "tflite_api_dispatcher",
|
name = "tflite_api_dispatcher",
|
||||||
hdrs = ["tflite_api_dispatcher.h"],
|
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 = [
|
deps = [
|
||||||
"//tensorflow/lite:framework_lib",
|
"//tensorflow/lite:framework_lib",
|
||||||
] + tflite_experimental_runtime_linkopts(),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
@ -24,14 +17,5 @@ cc_library(
|
|||||||
deps = [
|
deps = [
|
||||||
":tflite_api_dispatcher",
|
":tflite_api_dispatcher",
|
||||||
"//tensorflow/lite:framework_lib",
|
"//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",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
@ -18,25 +18,12 @@ limitations under the License.
|
|||||||
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_TFLITE_API_DISPATCHER_TFLITE_API_DISPATCHER_H_
|
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_TFLITE_API_DISPATCHER_TFLITE_API_DISPATCHER_H_
|
||||||
#define 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
|
#ifndef TFLITE_EXPERIMENTAL_RUNTIME
|
||||||
#define TFLITE_EXPERIMENTAL_RUNTIME_EAGER (0)
|
#define TFLITE_EXPERIMENTAL_RUNTIME (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."
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Import the relevant interpreter and model files.
|
// Import the relevant interpreter and model files.
|
||||||
#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
#if TFLITE_EXPERIMENTAL_RUNTIME
|
||||||
#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
|
|
||||||
#include "tensorflow/lite/experimental/tf_runtime/lib/model.h"
|
#include "tensorflow/lite/experimental/tf_runtime/lib/model.h"
|
||||||
#include "tensorflow/lite/experimental/tf_runtime/public/interpreter.h"
|
#include "tensorflow/lite/experimental/tf_runtime/public/interpreter.h"
|
||||||
#else
|
#else
|
||||||
@ -47,12 +34,7 @@ limitations under the License.
|
|||||||
namespace tflite_api_dispatcher {
|
namespace tflite_api_dispatcher {
|
||||||
|
|
||||||
// Use the correct interpreter.
|
// Use the correct interpreter.
|
||||||
#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
#if TFLITE_EXPERIMENTAL_RUNTIME
|
||||||
using Interpreter = tflrt::EagerInterpreter;
|
|
||||||
using InterpreterBuilder = tflrt::EagerTfLiteInterpreterBuilderAPI;
|
|
||||||
using TfLiteModel = tflite::FlatBufferModel;
|
|
||||||
using TfLiteVerifier = tflite::TfLiteVerifier;
|
|
||||||
#elif TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER
|
|
||||||
using Interpreter = tflrt::TfLiteInterpreterAPI;
|
using Interpreter = tflrt::TfLiteInterpreterAPI;
|
||||||
using InterpreterBuilder = tflrt::TfLiteInterpreterBuilderAPI;
|
using InterpreterBuilder = tflrt::TfLiteInterpreterBuilderAPI;
|
||||||
using TfLiteModel = tflrt::BEFModel;
|
using TfLiteModel = tflrt::BEFModel;
|
||||||
|
@ -52,8 +52,6 @@ static_assert(sizeof(TfLiteFloat16) == sizeof(uint16_t),
|
|||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Gets the current TfLiteQuantization from the legacy TfLiteQuantizationParams.
|
// Gets the current TfLiteQuantization from the legacy TfLiteQuantizationParams.
|
||||||
@ -475,6 +473,4 @@ Profiler* Interpreter::GetProfiler() {
|
|||||||
return primary_subgraph().GetProfiler();
|
return primary_subgraph().GetProfiler();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
@ -36,10 +36,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/lite/stderr_reporter.h"
|
#include "tensorflow/lite/stderr_reporter.h"
|
||||||
#include "tensorflow/lite/type_to_tflitetype.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 {
|
namespace tflite {
|
||||||
|
|
||||||
class InterpreterTest;
|
class InterpreterTest;
|
||||||
@ -48,8 +44,6 @@ namespace delegates {
|
|||||||
class InterpreterUtils; // Class for friend declarations.
|
class InterpreterUtils; // Class for friend declarations.
|
||||||
} // namespace delegates
|
} // namespace delegates
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
/// An interpreter for a graph of nodes that input and output from tensors.
|
/// 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
|
/// 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.
|
/// set of output Tensors. All inputs/output tensors are referenced by index.
|
||||||
@ -659,13 +653,5 @@ class Interpreter {
|
|||||||
std::vector<TfLiteDelegatePtr> lazy_delegate_providers_;
|
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
|
} // namespace tflite
|
||||||
#endif // TENSORFLOW_LITE_INTERPRETER_H_
|
#endif // TENSORFLOW_LITE_INTERPRETER_H_
|
||||||
|
@ -137,8 +137,6 @@ TFLITE_ATTRIBUTE_WEAK Interpreter::TfLiteDelegatePtr AcquireFlexDelegate() {
|
|||||||
return Interpreter::TfLiteDelegatePtr(nullptr, [](TfLiteDelegate*) {});
|
return Interpreter::TfLiteDelegatePtr(nullptr, [](TfLiteDelegate*) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
InterpreterBuilder::InterpreterBuilder(const FlatBufferModel& model,
|
InterpreterBuilder::InterpreterBuilder(const FlatBufferModel& model,
|
||||||
const OpResolver& op_resolver)
|
const OpResolver& op_resolver)
|
||||||
: model_(model.GetModel()),
|
: model_(model.GetModel()),
|
||||||
@ -679,6 +677,4 @@ TfLiteStatus InterpreterBuilder::operator()(
|
|||||||
return kTfLiteOk;
|
return kTfLiteOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
@ -30,8 +30,6 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
/// Build an interpreter capable of interpreting `model`.
|
/// Build an interpreter capable of interpreting `model`.
|
||||||
///
|
///
|
||||||
/// `model`: A model whose lifetime must be at least as long as any
|
/// `model`: A model whose lifetime must be at least as long as any
|
||||||
@ -96,8 +94,6 @@ class InterpreterBuilder {
|
|||||||
int num_fp32_tensors_ = 0;
|
int num_fp32_tensors_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
|
||||||
#endif // TENSORFLOW_LITE_INTERPRETER_BUILDER_H_
|
#endif // TENSORFLOW_LITE_INTERPRETER_BUILDER_H_
|
||||||
|
@ -18,23 +18,9 @@ limitations under the License.
|
|||||||
#ifndef TENSORFLOW_LITE_MODEL_H_
|
#ifndef TENSORFLOW_LITE_MODEL_H_
|
||||||
#define TENSORFLOW_LITE_MODEL_H_
|
#define TENSORFLOW_LITE_MODEL_H_
|
||||||
|
|
||||||
|
#include "tensorflow/lite/interpreter_builder.h"
|
||||||
#include "tensorflow/lite/model_builder.h"
|
#include "tensorflow/lite/model_builder.h"
|
||||||
|
|
||||||
#if TFLITE_EXPERIMENTAL_RUNTIME_EAGER
|
// TODO(b/168725050): Address the issue of proxy header in this file.
|
||||||
#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
|
|
||||||
|
|
||||||
#endif // TENSORFLOW_LITE_MODEL_H_
|
#endif // TENSORFLOW_LITE_MODEL_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user