From 225dd36a63fb77f0f9085c59ee78afe65adca5eb Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 7 Mar 2023 14:10:07 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 514835354 --- mediapipe/calculators/tensor/BUILD | 9 ++++++ .../inference_interpreter_delegate_runner.h | 6 +--- .../calculators/tensor/tflite_delegate_ptr.h | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 mediapipe/calculators/tensor/tflite_delegate_ptr.h diff --git a/mediapipe/calculators/tensor/BUILD b/mediapipe/calculators/tensor/BUILD index c66665b6..b4461b46 100644 --- a/mediapipe/calculators/tensor/BUILD +++ b/mediapipe/calculators/tensor/BUILD @@ -476,11 +476,20 @@ cc_library( ], ) +cc_library_with_tflite( + name = "tflite_delegate_ptr", + hdrs = ["tflite_delegate_ptr.h"], + tflite_deps = [ + "@org_tensorflow//tensorflow/lite/core/shims:c_api_types", + ], +) + cc_library_with_tflite( name = "inference_interpreter_delegate_runner", srcs = ["inference_interpreter_delegate_runner.cc"], hdrs = ["inference_interpreter_delegate_runner.h"], tflite_deps = [ + ":tflite_delegate_ptr", "//mediapipe/util/tflite:tflite_model_loader", "@org_tensorflow//tensorflow/lite/core/shims:c_api_types", "@org_tensorflow//tensorflow/lite/core/shims:framework_stable", diff --git a/mediapipe/calculators/tensor/inference_interpreter_delegate_runner.h b/mediapipe/calculators/tensor/inference_interpreter_delegate_runner.h index 44d6a932..d2035c99 100644 --- a/mediapipe/calculators/tensor/inference_interpreter_delegate_runner.h +++ b/mediapipe/calculators/tensor/inference_interpreter_delegate_runner.h @@ -20,6 +20,7 @@ #include "absl/status/statusor.h" #include "mediapipe/calculators/tensor/inference_runner.h" +#include "mediapipe/calculators/tensor/tflite_delegate_ptr.h" #include "mediapipe/framework/api2/packet.h" #include "mediapipe/util/tflite/tflite_model_loader.h" #include "tensorflow/lite/core/api/op_resolver.h" @@ -27,11 +28,6 @@ namespace mediapipe { -// TODO: Consider renaming TfLiteDelegatePtr. -using TfLiteDelegatePtr = - std::unique_ptr>; - // Creates inference runner which run inference using newly initialized // interpreter and provided `delegate`. // diff --git a/mediapipe/calculators/tensor/tflite_delegate_ptr.h b/mediapipe/calculators/tensor/tflite_delegate_ptr.h new file mode 100644 index 00000000..caaa19c2 --- /dev/null +++ b/mediapipe/calculators/tensor/tflite_delegate_ptr.h @@ -0,0 +1,32 @@ +// Copyright 2022 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef MEDIAPIPE_CALCULATORS_TENSOR_TFLITE_DELEGATE_PTR_H_ +#define MEDIAPIPE_CALCULATORS_TENSOR_TFLITE_DELEGATE_PTR_H_ + +#include +#include + +#include "tensorflow/lite/core/shims/c/c_api_types.h" + +namespace mediapipe { + +// TODO: Consider renaming TfLiteDelegatePtr. +using TfLiteDelegatePtr = + std::unique_ptr>; + +} // namespace mediapipe + +#endif // MEDIAPIPE_CALCULATORS_TENSOR_TFLITE_DELEGATE_PTR_H_