Update MediaPipe TFLite code to use generic "shim" symbols and headers

PiperOrigin-RevId: 511265313
This commit is contained in:
MediaPipe Team 2023-02-21 11:56:22 -08:00 committed by Copybara-Service
parent 8a0830ce7b
commit 9a6d5e0444
6 changed files with 13 additions and 13 deletions

View File

@ -320,7 +320,7 @@ cc_library(
"//mediapipe/framework:packet", "//mediapipe/framework:packet",
"//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:ret_check",
"@com_google_absl//absl/status", "@com_google_absl//absl/status",
"@org_tensorflow//tensorflow/lite:framework", "@org_tensorflow//tensorflow/lite/core/shims:framework_stable",
], ],
alwayslink = 1, alwayslink = 1,
) )

View File

@ -66,7 +66,7 @@ class TfLiteCustomOpResolverCalculator : public CalculatorBase {
} else { } else {
cc->OutputSidePackets() cc->OutputSidePackets()
.Index(0) .Index(0)
.Set<tflite::ops::builtin::BuiltinOpResolver>(); .Set<tflite_shims::ops::builtin::BuiltinOpResolver>();
} }
return absl::OkStatus(); return absl::OkStatus();
} }
@ -77,7 +77,7 @@ class TfLiteCustomOpResolverCalculator : public CalculatorBase {
const TfLiteCustomOpResolverCalculatorOptions& options = const TfLiteCustomOpResolverCalculatorOptions& options =
cc->Options<TfLiteCustomOpResolverCalculatorOptions>(); cc->Options<TfLiteCustomOpResolverCalculatorOptions>();
std::unique_ptr<tflite::ops::builtin::BuiltinOpResolver> op_resolver; std::unique_ptr<tflite_shims::ops::builtin::BuiltinOpResolver> op_resolver;
if (options.use_gpu()) { if (options.use_gpu()) {
op_resolver = absl::make_unique<mediapipe::OpResolver>(); op_resolver = absl::make_unique<mediapipe::OpResolver>();
} else { } else {

View File

@ -21,7 +21,7 @@
#include "mediapipe/framework/packet.h" #include "mediapipe/framework/packet.h"
#include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/ret_check.h"
#include "tensorflow/lite/allocation.h" #include "tensorflow/lite/allocation.h"
#include "tensorflow/lite/model.h" #include "tensorflow/lite/core/shims/cc/model.h"
namespace mediapipe { namespace mediapipe {

View File

@ -44,8 +44,8 @@ cc_library(
"//mediapipe/util/tflite/operations:transform_tensor_bilinear", "//mediapipe/util/tflite/operations:transform_tensor_bilinear",
"//mediapipe/util/tflite/operations:transpose_conv_bias", "//mediapipe/util/tflite/operations:transpose_conv_bias",
"@org_tensorflow//tensorflow/lite:builtin_op_data", "@org_tensorflow//tensorflow/lite:builtin_op_data",
"@org_tensorflow//tensorflow/lite:framework", "@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
"@org_tensorflow//tensorflow/lite/kernels:builtin_ops", "@org_tensorflow//tensorflow/lite/core/shims:framework_stable",
], ],
# For using the symbol `MediaPipe_RegisterTfLiteOpResolver` in Python # For using the symbol `MediaPipe_RegisterTfLiteOpResolver` in Python
# with `tensorflow.lite.python.interpreter.InterpreterWithCustomOps`. # with `tensorflow.lite.python.interpreter.InterpreterWithCustomOps`.
@ -69,7 +69,7 @@ cc_library(
hdrs = ["op_resolver.h"], hdrs = ["op_resolver.h"],
deps = [ deps = [
"@org_tensorflow//tensorflow/lite:builtin_op_data", "@org_tensorflow//tensorflow/lite:builtin_op_data",
"@org_tensorflow//tensorflow/lite/kernels:builtin_ops", "@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
], ],
) )

View File

@ -15,7 +15,7 @@
#ifndef MEDIAPIPE_UTIL_TFLITE_CPU_OP_RESOLVER_H_ #ifndef MEDIAPIPE_UTIL_TFLITE_CPU_OP_RESOLVER_H_
#define MEDIAPIPE_UTIL_TFLITE_CPU_OP_RESOLVER_H_ #define MEDIAPIPE_UTIL_TFLITE_CPU_OP_RESOLVER_H_
#include "tensorflow/lite/kernels/register.h" #include "tensorflow/lite/core/shims/cc/kernels/register.h"
namespace mediapipe { namespace mediapipe {
@ -27,8 +27,8 @@ extern "C" void MediaPipe_RegisterTfLiteOpResolver(tflite::MutableOpResolver*);
// This resolver is used for the custom ops introduced by // This resolver is used for the custom ops introduced by
// `MediaPipe_RegisterTfLiteOpResolver` (see above). // `MediaPipe_RegisterTfLiteOpResolver` (see above).
class CpuOpResolver class CpuOpResolver : public tflite_shims::ops::builtin::
: public tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates { BuiltinOpResolverWithoutDefaultDelegates {
public: public:
CpuOpResolver() { MediaPipe_RegisterTfLiteOpResolver(this); } CpuOpResolver() { MediaPipe_RegisterTfLiteOpResolver(this); }
}; };

View File

@ -15,13 +15,13 @@
#ifndef MEDIAPIPE_UTIL_TFLITE_OP_RESOLVER_H_ #ifndef MEDIAPIPE_UTIL_TFLITE_OP_RESOLVER_H_
#define MEDIAPIPE_UTIL_TFLITE_OP_RESOLVER_H_ #define MEDIAPIPE_UTIL_TFLITE_OP_RESOLVER_H_
#include "tensorflow/lite/kernels/register.h" #include "tensorflow/lite/core/shims/cc/kernels/register.h"
namespace mediapipe { namespace mediapipe {
// This OpResolver is used for supporting "Convolution2DTransposeBias" on GPU. // This OpResolver is used for supporting "Convolution2DTransposeBias" on GPU.
class OpResolver class OpResolver : public tflite_shims::ops::builtin::
: public tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates { BuiltinOpResolverWithoutDefaultDelegates {
public: public:
OpResolver(); OpResolver();
}; };