Internal change
PiperOrigin-RevId: 293480979 Change-Id: I6f6f0be8d502c375db5e1a122abd18231c002f87
This commit is contained in:
parent
548fcc85ff
commit
c04624500d
tensorflow/lite
@ -38,8 +38,14 @@ config_setting(
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "tflite_experimental_runtime",
|
||||
values = {"define": "tflite_experimental_runtime=true"},
|
||||
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"],
|
||||
)
|
||||
|
||||
|
@ -702,17 +702,22 @@ 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_true, if_false = []):
|
||||
def if_tflite_experimental_runtime(if_eager, if_non_eager, if_none = []):
|
||||
return select({
|
||||
"//tensorflow/lite:tflite_experimental_runtime": if_true,
|
||||
"//conditions:default": if_false,
|
||||
"//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_true = [], if_false = []):
|
||||
def tflite_experimental_runtime_linkopts(if_eager = [], if_non_eager = [], if_none = []):
|
||||
return if_tflite_experimental_runtime(
|
||||
if_true = [
|
||||
if_eager = [
|
||||
# "//tensorflow/lite/experimental/tf_runtime:eager_interpreter",
|
||||
# "//tensorflow/lite/experimental/tf_runtime:eager_model",
|
||||
] + if_eager,
|
||||
if_non_eager = [
|
||||
# "//tensorflow/lite/experimental/tf_runtime:interpreter",
|
||||
# "//tensorflow/lite/experimental/tf_runtime:model",
|
||||
] + if_true,
|
||||
if_false = [] + if_false,
|
||||
] + if_non_eager,
|
||||
if_none = [] + if_none,
|
||||
)
|
||||
|
@ -9,8 +9,9 @@ cc_library(
|
||||
name = "tflite_api_dispatcher",
|
||||
hdrs = ["tflite_api_dispatcher.h"],
|
||||
defines = if_tflite_experimental_runtime(
|
||||
if_false = [],
|
||||
if_true = ["TFLITE_EXPERIMENTAL_RUNTIME"],
|
||||
if_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_EAGER"],
|
||||
if_non_eager = ["TFLITE_EXPERIMENTAL_RUNTIME_NON_EAGER"],
|
||||
if_none = [],
|
||||
),
|
||||
deps = [
|
||||
"//tensorflow/lite:framework",
|
||||
@ -24,7 +25,7 @@ cc_library(
|
||||
":tflite_api_dispatcher",
|
||||
"//tensorflow/lite:framework",
|
||||
] + tflite_experimental_runtime_linkopts(
|
||||
if_true = [
|
||||
if_non_eager = [
|
||||
# "//tensorflow/lite/experimental/tf_runtime/tfrt_kernels:tfrt_tflite_interpreter_alwayslink",
|
||||
# "//third_party/tf_runtime:basic_kernels_alwayslink",
|
||||
],
|
||||
|
@ -18,12 +18,25 @@ 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
|
||||
#define TFLITE_EXPERIMENTAL_RUNTIME (0)
|
||||
#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."
|
||||
#endif
|
||||
|
||||
// Import the relevant interpreter and model files.
|
||||
#if TFLITE_EXPERIMENTAL_RUNTIME
|
||||
#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
|
||||
#include "tensorflow/lite/experimental/tf_runtime/lib/model.h"
|
||||
#include "tensorflow/lite/experimental/tf_runtime/public/interpreter.h"
|
||||
#else
|
||||
@ -34,7 +47,12 @@ limitations under the License.
|
||||
namespace tflite_api_dispatcher {
|
||||
|
||||
// Use the correct interpreter.
|
||||
#if TFLITE_EXPERIMENTAL_RUNTIME
|
||||
#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
|
||||
using Interpreter = tflrt::TfLiteInterpreterAPI;
|
||||
using InterpreterBuilder = tflrt::TfLiteInterpreterBuilderAPI;
|
||||
using TfLiteModel = tflrt::BEFModel;
|
||||
|
Loading…
Reference in New Issue
Block a user