From 9a6d5e044427782f0468c5a056221008253495f6 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 21 Feb 2023 11:56:22 -0800 Subject: [PATCH] Update MediaPipe TFLite code to use generic "shim" symbols and headers PiperOrigin-RevId: 511265313 --- mediapipe/calculators/tflite/BUILD | 2 +- .../tflite/tflite_custom_op_resolver_calculator.cc | 4 ++-- mediapipe/calculators/tflite/tflite_model_calculator.cc | 2 +- mediapipe/util/tflite/BUILD | 6 +++--- mediapipe/util/tflite/cpu_op_resolver.h | 6 +++--- mediapipe/util/tflite/op_resolver.h | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mediapipe/calculators/tflite/BUILD b/mediapipe/calculators/tflite/BUILD index 94d4f40fe..9dcb0f733 100644 --- a/mediapipe/calculators/tflite/BUILD +++ b/mediapipe/calculators/tflite/BUILD @@ -320,7 +320,7 @@ cc_library( "//mediapipe/framework:packet", "//mediapipe/framework/port:ret_check", "@com_google_absl//absl/status", - "@org_tensorflow//tensorflow/lite:framework", + "@org_tensorflow//tensorflow/lite/core/shims:framework_stable", ], alwayslink = 1, ) diff --git a/mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator.cc b/mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator.cc index 950d742a9..3a5ae8282 100644 --- a/mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator.cc @@ -66,7 +66,7 @@ class TfLiteCustomOpResolverCalculator : public CalculatorBase { } else { cc->OutputSidePackets() .Index(0) - .Set(); + .Set(); } return absl::OkStatus(); } @@ -77,7 +77,7 @@ class TfLiteCustomOpResolverCalculator : public CalculatorBase { const TfLiteCustomOpResolverCalculatorOptions& options = cc->Options(); - std::unique_ptr op_resolver; + std::unique_ptr op_resolver; if (options.use_gpu()) { op_resolver = absl::make_unique(); } else { diff --git a/mediapipe/calculators/tflite/tflite_model_calculator.cc b/mediapipe/calculators/tflite/tflite_model_calculator.cc index 891a9f731..435ea0127 100644 --- a/mediapipe/calculators/tflite/tflite_model_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_model_calculator.cc @@ -21,7 +21,7 @@ #include "mediapipe/framework/packet.h" #include "mediapipe/framework/port/ret_check.h" #include "tensorflow/lite/allocation.h" -#include "tensorflow/lite/model.h" +#include "tensorflow/lite/core/shims/cc/model.h" namespace mediapipe { diff --git a/mediapipe/util/tflite/BUILD b/mediapipe/util/tflite/BUILD index 26d73a6a6..da58d59cf 100644 --- a/mediapipe/util/tflite/BUILD +++ b/mediapipe/util/tflite/BUILD @@ -44,8 +44,8 @@ cc_library( "//mediapipe/util/tflite/operations:transform_tensor_bilinear", "//mediapipe/util/tflite/operations:transpose_conv_bias", "@org_tensorflow//tensorflow/lite:builtin_op_data", - "@org_tensorflow//tensorflow/lite:framework", - "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "@org_tensorflow//tensorflow/lite/core/shims:builtin_ops", + "@org_tensorflow//tensorflow/lite/core/shims:framework_stable", ], # For using the symbol `MediaPipe_RegisterTfLiteOpResolver` in Python # with `tensorflow.lite.python.interpreter.InterpreterWithCustomOps`. @@ -69,7 +69,7 @@ cc_library( hdrs = ["op_resolver.h"], deps = [ "@org_tensorflow//tensorflow/lite:builtin_op_data", - "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "@org_tensorflow//tensorflow/lite/core/shims:builtin_ops", ], ) diff --git a/mediapipe/util/tflite/cpu_op_resolver.h b/mediapipe/util/tflite/cpu_op_resolver.h index 887683013..173531f11 100644 --- a/mediapipe/util/tflite/cpu_op_resolver.h +++ b/mediapipe/util/tflite/cpu_op_resolver.h @@ -15,7 +15,7 @@ #ifndef 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 { @@ -27,8 +27,8 @@ extern "C" void MediaPipe_RegisterTfLiteOpResolver(tflite::MutableOpResolver*); // This resolver is used for the custom ops introduced by // `MediaPipe_RegisterTfLiteOpResolver` (see above). -class CpuOpResolver - : public tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates { +class CpuOpResolver : public tflite_shims::ops::builtin:: + BuiltinOpResolverWithoutDefaultDelegates { public: CpuOpResolver() { MediaPipe_RegisterTfLiteOpResolver(this); } }; diff --git a/mediapipe/util/tflite/op_resolver.h b/mediapipe/util/tflite/op_resolver.h index 4ca179ef1..8b04d5f1a 100644 --- a/mediapipe/util/tflite/op_resolver.h +++ b/mediapipe/util/tflite/op_resolver.h @@ -15,13 +15,13 @@ #ifndef 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 { // This OpResolver is used for supporting "Convolution2DTransposeBias" on GPU. -class OpResolver - : public tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates { +class OpResolver : public tflite_shims::ops::builtin:: + BuiltinOpResolverWithoutDefaultDelegates { public: OpResolver(); };