Modified internal dependencies.
PiperOrigin-RevId: 484407262
This commit is contained in:
parent
abd1ff66c8
commit
de5fe27e05
|
@ -84,33 +84,28 @@ cc_library(
|
||||||
"//conditions:default": ["tflite_gpu_runner.h"],
|
"//conditions:default": ["tflite_gpu_runner.h"],
|
||||||
}),
|
}),
|
||||||
deps = select({
|
deps = select({
|
||||||
"//mediapipe:ios": [],
|
"//mediapipe:ios": [],
|
||||||
"//mediapipe:macos": [],
|
"//mediapipe:macos": [],
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"@org_tensorflow//tensorflow/lite:framework",
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu:api",
|
"@org_tensorflow//tensorflow/lite/delegates/gpu:api",
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model",
|
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model",
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model_builder",
|
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model_builder",
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:api2",
|
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:api2",
|
||||||
],
|
],
|
||||||
"//mediapipe:android": [
|
}) +
|
||||||
"@com_google_absl//absl/strings",
|
select({
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe:android": [
|
||||||
"//mediapipe/framework/port:status",
|
"@org_tensorflow//tensorflow/lite/delegates/gpu/cl:api",
|
||||||
"//mediapipe/framework/port:statusor",
|
],
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"//conditions:default": [],
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu:api",
|
}) + [
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/cl:api",
|
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model",
|
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/common:model_builder",
|
|
||||||
"@org_tensorflow//tensorflow/lite/delegates/gpu/gl:api2",
|
|
||||||
],
|
|
||||||
}) + [
|
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
|
"//mediapipe/framework:port",
|
||||||
"@org_tensorflow//tensorflow/lite/core/api",
|
"@org_tensorflow//tensorflow/lite/core/api",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
// This code should be enabled as soon as TensorFlow version, which mediapipe
|
// This code should be enabled as soon as TensorFlow version, which mediapipe
|
||||||
// uses, will include this module.
|
// uses, will include this module.
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
#include "tensorflow/lite/delegates/gpu/cl/api.h"
|
#include "tensorflow/lite/delegates/gpu/cl/api.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ ObjectDef GetSSBOObjectDef(int channels) {
|
||||||
return gpu_object_def;
|
return gpu_object_def;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
cl::InferenceOptions GetClInferenceOptions(const InferenceOptions& options) {
|
cl::InferenceOptions GetClInferenceOptions(const InferenceOptions& options) {
|
||||||
cl::InferenceOptions result{};
|
cl::InferenceOptions result{};
|
||||||
|
@ -106,7 +106,7 @@ absl::Status VerifyShapes(const std::vector<TensorObjectDef>& actual,
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ absl::Status TFLiteGPURunner::InitializeOpenGL(
|
||||||
|
|
||||||
absl::Status TFLiteGPURunner::InitializeOpenCL(
|
absl::Status TFLiteGPURunner::InitializeOpenCL(
|
||||||
std::unique_ptr<InferenceBuilder>* builder) {
|
std::unique_ptr<InferenceBuilder>* builder) {
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
cl::InferenceEnvironmentOptions env_options;
|
cl::InferenceEnvironmentOptions env_options;
|
||||||
if (!serialized_binary_cache_.empty()) {
|
if (!serialized_binary_cache_.empty()) {
|
||||||
env_options.serialized_binary_cache = serialized_binary_cache_;
|
env_options.serialized_binary_cache = serialized_binary_cache_;
|
||||||
|
@ -254,11 +254,12 @@ absl::Status TFLiteGPURunner::InitializeOpenCL(
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
#else
|
#else
|
||||||
return mediapipe::UnimplementedError("Currently only Android is supported");
|
return mediapipe::UnimplementedError(
|
||||||
#endif // __ANDROID__
|
"Currently only Android & ChromeOS are supported");
|
||||||
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
absl::Status TFLiteGPURunner::InitializeOpenCLFromSerializedModel(
|
absl::Status TFLiteGPURunner::InitializeOpenCLFromSerializedModel(
|
||||||
std::unique_ptr<InferenceBuilder>* builder) {
|
std::unique_ptr<InferenceBuilder>* builder) {
|
||||||
|
@ -283,7 +284,7 @@ absl::StatusOr<std::vector<uint8_t>> TFLiteGPURunner::GetSerializedModel() {
|
||||||
return serialized_model;
|
return serialized_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
} // namespace tflite
|
} // namespace tflite
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
#include "mediapipe/framework/port.h"
|
||||||
#include "mediapipe/framework/port/status.h"
|
#include "mediapipe/framework/port/status.h"
|
||||||
#include "mediapipe/framework/port/statusor.h"
|
#include "mediapipe/framework/port/statusor.h"
|
||||||
#include "tensorflow/lite/core/api/op_resolver.h"
|
#include "tensorflow/lite/core/api/op_resolver.h"
|
||||||
|
@ -28,9 +29,9 @@
|
||||||
#include "tensorflow/lite/delegates/gpu/gl/api2.h"
|
#include "tensorflow/lite/delegates/gpu/gl/api2.h"
|
||||||
#include "tensorflow/lite/model.h"
|
#include "tensorflow/lite/model.h"
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
#include "tensorflow/lite/delegates/gpu/cl/api.h"
|
#include "tensorflow/lite/delegates/gpu/cl/api.h"
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
namespace tflite {
|
namespace tflite {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
@ -83,7 +84,7 @@ class TFLiteGPURunner {
|
||||||
return output_shape_from_model_;
|
return output_shape_from_model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
void SetSerializedBinaryCache(std::vector<uint8_t>&& cache) {
|
void SetSerializedBinaryCache(std::vector<uint8_t>&& cache) {
|
||||||
serialized_binary_cache_ = std::move(cache);
|
serialized_binary_cache_ = std::move(cache);
|
||||||
}
|
}
|
||||||
|
@ -98,26 +99,26 @@ class TFLiteGPURunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> GetSerializedModel();
|
absl::StatusOr<std::vector<uint8_t>> GetSerializedModel();
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status InitializeOpenGL(std::unique_ptr<InferenceBuilder>* builder);
|
absl::Status InitializeOpenGL(std::unique_ptr<InferenceBuilder>* builder);
|
||||||
absl::Status InitializeOpenCL(std::unique_ptr<InferenceBuilder>* builder);
|
absl::Status InitializeOpenCL(std::unique_ptr<InferenceBuilder>* builder);
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
absl::Status InitializeOpenCLFromSerializedModel(
|
absl::Status InitializeOpenCLFromSerializedModel(
|
||||||
std::unique_ptr<InferenceBuilder>* builder);
|
std::unique_ptr<InferenceBuilder>* builder);
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
InferenceOptions options_;
|
InferenceOptions options_;
|
||||||
std::unique_ptr<gl::InferenceEnvironment> gl_environment_;
|
std::unique_ptr<gl::InferenceEnvironment> gl_environment_;
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
std::unique_ptr<cl::InferenceEnvironment> cl_environment_;
|
std::unique_ptr<cl::InferenceEnvironment> cl_environment_;
|
||||||
|
|
||||||
std::vector<uint8_t> serialized_binary_cache_;
|
std::vector<uint8_t> serialized_binary_cache_;
|
||||||
std::vector<uint8_t> serialized_model_;
|
std::vector<uint8_t> serialized_model_;
|
||||||
bool serialized_model_used_ = false;
|
bool serialized_model_used_ = false;
|
||||||
#endif // __ANDROID__
|
#endif // defined(__ANDROID__) || defined(MEDIAPIPE_CHROMIUMOS)
|
||||||
|
|
||||||
// graph_gl_ is maintained temporarily and becomes invalid after runner_ is
|
// graph_gl_ is maintained temporarily and becomes invalid after runner_ is
|
||||||
// ready
|
// ready
|
||||||
|
|
Loading…
Reference in New Issue
Block a user