From 6c68d4c358b7f165f5f9d70deb8ca71dec540c3e Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Mon, 6 Mar 2023 08:40:18 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 514421618 --- mediapipe/framework/BUILD | 37 +++++++++----------- mediapipe/framework/calculator_graph.cc | 4 +-- mediapipe/framework/calculator_graph.h | 6 +++- mediapipe/framework/calculator_graph_test.cc | 2 +- mediapipe/gpu/BUILD | 2 +- mediapipe/gpu/MPPMetalHelper.mm | 1 + mediapipe/gpu/gpu_service.h | 2 +- mediapipe/gpu/gpu_shared_data_internal.cc | 4 +-- mediapipe/gpu/graph_support.h | 6 ---- 9 files changed, 29 insertions(+), 35 deletions(-) diff --git a/mediapipe/framework/BUILD b/mediapipe/framework/BUILD index 5830a4c05..19fa6f469 100644 --- a/mediapipe/framework/BUILD +++ b/mediapipe/framework/BUILD @@ -305,15 +305,16 @@ cc_library( ], deps = [ ":calculator_base", + ":calculator_cc_proto", ":calculator_node", ":counter_factory", ":delegating_executor", - ":mediapipe_profiling", ":executor", ":graph_output_stream", ":graph_service", ":graph_service_manager", ":input_stream_manager", + ":mediapipe_profiling", ":output_side_packet_impl", ":output_stream", ":output_stream_manager", @@ -321,28 +322,18 @@ cc_library( ":output_stream_shard", ":packet", ":packet_generator", + ":packet_generator_cc_proto", ":packet_generator_graph", ":packet_set", ":packet_type", ":port", ":scheduler_queue", ":status_handler", + ":status_handler_cc_proto", ":thread_pool_executor", + ":thread_pool_executor_cc_proto", ":timestamp", ":validated_graph_config", - ":calculator_cc_proto", - ":packet_generator_cc_proto", - ":status_handler_cc_proto", - ":thread_pool_executor_cc_proto", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/container:fixed_array", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/status", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@com_google_absl//absl/synchronization", "//mediapipe/framework/port:core_proto", "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:logging", @@ -355,13 +346,19 @@ cc_library( "//mediapipe/framework/tool:tag_map", "//mediapipe/framework/tool:validate", "//mediapipe/framework/tool:validate_name", - "//mediapipe/gpu:graph_support", "//mediapipe/gpu:gpu_service", + "//mediapipe/gpu:graph_support", "//mediapipe/util:cpu_util", - ] + select({ - "//conditions:default": ["//mediapipe/gpu:gpu_shared_data_internal"], - "//mediapipe/gpu:disable_gpu": [], - }), + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/container:fixed_array", + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/synchronization", + ], ) cc_library( @@ -1434,7 +1431,7 @@ cc_test( "//mediapipe/framework/stream_handler:timestamp_align_input_stream_handler", "//mediapipe/framework/tool:sink", "//mediapipe/framework/tool:status_util", - "//mediapipe/gpu:graph_support", + "//mediapipe/gpu:gpu_service", "@com_google_absl//absl/container:fixed_array", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", diff --git a/mediapipe/framework/calculator_graph.cc b/mediapipe/framework/calculator_graph.cc index 291e93734..d803d7141 100644 --- a/mediapipe/framework/calculator_graph.cc +++ b/mediapipe/framework/calculator_graph.cc @@ -62,11 +62,9 @@ #include "mediapipe/framework/tool/validate.h" #include "mediapipe/framework/tool/validate_name.h" #include "mediapipe/framework/validated_graph_config.h" +#include "mediapipe/gpu/gpu_service.h" #include "mediapipe/gpu/graph_support.h" #include "mediapipe/util/cpu_util.h" -#if !MEDIAPIPE_DISABLE_GPU -#include "mediapipe/gpu/gpu_shared_data_internal.h" -#endif // !MEDIAPIPE_DISABLE_GPU namespace mediapipe { diff --git a/mediapipe/framework/calculator_graph.h b/mediapipe/framework/calculator_graph.h index 85febaa26..93dbfe8dc 100644 --- a/mediapipe/framework/calculator_graph.h +++ b/mediapipe/framework/calculator_graph.h @@ -53,10 +53,14 @@ #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/scheduler.h" #include "mediapipe/framework/thread_pool_executor.pb.h" -#include "mediapipe/gpu/gpu_service.h" namespace mediapipe { +#if !MEDIAPIPE_DISABLE_GPU +class GpuResources; +struct GpuSharedData; +#endif // !MEDIAPIPE_DISABLE_GPU + typedef absl::StatusOr StatusOrPoller; // The class representing a DAG of calculator nodes. diff --git a/mediapipe/framework/calculator_graph_test.cc b/mediapipe/framework/calculator_graph_test.cc index f982400cf..6ca206ab1 100644 --- a/mediapipe/framework/calculator_graph_test.cc +++ b/mediapipe/framework/calculator_graph_test.cc @@ -60,7 +60,7 @@ #include "mediapipe/framework/tool/sink.h" #include "mediapipe/framework/tool/status_util.h" #include "mediapipe/framework/type_map.h" -#include "mediapipe/gpu/graph_support.h" +#include "mediapipe/gpu/gpu_service.h" namespace mediapipe { diff --git a/mediapipe/gpu/BUILD b/mediapipe/gpu/BUILD index bac4cd933..fe1cab29d 100644 --- a/mediapipe/gpu/BUILD +++ b/mediapipe/gpu/BUILD @@ -50,7 +50,6 @@ cc_library( name = "graph_support", hdrs = ["graph_support.h"], visibility = ["//visibility:public"], - deps = ["//mediapipe/framework:graph_service"], ) cc_library( @@ -827,6 +826,7 @@ objc_library( features = ["-layering_check"], visibility = ["//visibility:public"], deps = [ + ":gpu_service", ":gpu_shared_data_internal", ":graph_support", "//mediapipe/objc:mediapipe_framework_ios", diff --git a/mediapipe/gpu/MPPMetalHelper.mm b/mediapipe/gpu/MPPMetalHelper.mm index 1acf7cbfb..c0703e6ee 100644 --- a/mediapipe/gpu/MPPMetalHelper.mm +++ b/mediapipe/gpu/MPPMetalHelper.mm @@ -16,6 +16,7 @@ #import "mediapipe/gpu/gpu_buffer.h" #import "mediapipe/gpu/graph_support.h" +#import "mediapipe/gpu/gpu_service.h" #import "mediapipe/gpu/metal_shared_resources.h" #import "GTMDefines.h" diff --git a/mediapipe/gpu/gpu_service.h b/mediapipe/gpu/gpu_service.h index aa5990036..65fecd0b8 100644 --- a/mediapipe/gpu/gpu_service.h +++ b/mediapipe/gpu/gpu_service.h @@ -27,7 +27,7 @@ namespace mediapipe { class GpuResources { GpuResources() = delete; }; -#endif // !MEDIAPIPE_DISABLE_GPU +#endif // MEDIAPIPE_DISABLE_GPU extern const GraphService kGpuService; diff --git a/mediapipe/gpu/gpu_shared_data_internal.cc b/mediapipe/gpu/gpu_shared_data_internal.cc index 203a8dfd1..49e9cf22a 100644 --- a/mediapipe/gpu/gpu_shared_data_internal.cc +++ b/mediapipe/gpu/gpu_shared_data_internal.cc @@ -116,6 +116,8 @@ GpuResources::~GpuResources() { #endif // __APPLE__ } +extern const GraphService kGpuService; + absl::Status GpuResources::PrepareGpuNode(CalculatorNode* node) { CHECK(ContainsKey(node->Contract().ServiceRequests(), kGpuService.key)); std::string node_id = node->GetCalculatorState().NodeName(); @@ -195,8 +197,6 @@ GlContext::StatusOrGlContext GpuResources::GetOrCreateGlContext( GpuSharedData::GpuSharedData() : GpuSharedData(kPlatformGlContextNone) {} -extern const GraphService kGpuService; - #if !MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER static std::shared_ptr GetGlTextureBufferFromPool( int width, int height, GpuBufferFormat format) { diff --git a/mediapipe/gpu/graph_support.h b/mediapipe/gpu/graph_support.h index 6541771c8..7300623d6 100644 --- a/mediapipe/gpu/graph_support.h +++ b/mediapipe/gpu/graph_support.h @@ -16,14 +16,8 @@ #ifndef MEDIAPIPE_GPU_GRAPH_SUPPORT_H_ #define MEDIAPIPE_GPU_GRAPH_SUPPORT_H_ -#include "mediapipe/framework/graph_service.h" - namespace mediapipe { -// Forward declaration to avoid depending on GpuResources here. -class GpuResources; -extern const GraphService kGpuService; - static constexpr char kGpuSharedTagName[] = "GPU_SHARED"; static constexpr char kGpuSharedSidePacketName[] = "gpu_shared"; static constexpr char kGpuExecutorName[] = "__gpu";