From 7a7cc77a8154c6ac873763d39e54b14ae4de403a Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 19 Jan 2023 07:17:40 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 503157344 --- .../unpack_media_sequence_calculator_test.cc | 2 +- .../framework/calculator_context_test.cc | 4 ++-- mediapipe/framework/port/proto_ns.h | 5 +++-- .../framework/profiler/graph_profiler_test.cc | 18 ++++++++------- .../framework/tool/options_lib_template.cc | 2 +- mediapipe/framework/tool/options_registry.cc | 22 ++++++++++--------- mediapipe/framework/tool/options_registry.h | 2 +- 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc index d8562ffc4..fbf775403 100644 --- a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc @@ -647,7 +647,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetAudioDecoderOptionsOverride) { TEST_F(UnpackMediaSequenceCalculatorTest, GetPacketResamplingOptions) { // TODO: Suport proto3 proto.Any in CalculatorOptions. - // TODO: Avoid proto2 extensions in "RESAMPLER_OPTIONS". + // TODO: Avoid google::protobuf extensions in "RESAMPLER_OPTIONS". CalculatorOptions options; options.MutableExtension(UnpackMediaSequenceCalculatorOptions::ext) ->set_padding_before_label(1); diff --git a/mediapipe/framework/calculator_context_test.cc b/mediapipe/framework/calculator_context_test.cc index e7612501a..be9103b4d 100644 --- a/mediapipe/framework/calculator_context_test.cc +++ b/mediapipe/framework/calculator_context_test.cc @@ -131,10 +131,10 @@ TEST(CalculatorTest, GetOptions) { auto calculator_state_3 = MakeCalculatorState(config.node(3), 3); auto cc_3 = MakeCalculatorContext(&*calculator_state_3); - // Get a proto2 options extension from Node::options. + // Get a google::protobuf options extension from Node::options. EXPECT_EQ(cc_0->Options().jitter(), 0.123); - // Get a proto2 options extension from Node::node_options. + // Get a google::protobuf options extension from Node::node_options. EXPECT_EQ(cc_1->Options().jitter(), 0.123); // Get a proto3 options protobuf::Any from Node::node_options. diff --git a/mediapipe/framework/port/proto_ns.h b/mediapipe/framework/port/proto_ns.h index 83aecdf49..53b854ff7 100644 --- a/mediapipe/framework/port/proto_ns.h +++ b/mediapipe/framework/port/proto_ns.h @@ -17,8 +17,9 @@ #include -// Temporary forward declarations for proto2 support on portable targets. -// Use proto_ns inside namespace mediapipe instead of proto2 namespace. +// Temporary forward declarations for google::protobuf support on portable +// targets. Use proto_ns inside namespace mediapipe instead of google::protobuf +// namespace. #include "google/protobuf/message.h" #include "google/protobuf/message_lite.h" #include "google/protobuf/repeated_field.h" diff --git a/mediapipe/framework/profiler/graph_profiler_test.cc b/mediapipe/framework/profiler/graph_profiler_test.cc index 75d1c7ebd..e9badaa25 100644 --- a/mediapipe/framework/profiler/graph_profiler_test.cc +++ b/mediapipe/framework/profiler/graph_profiler_test.cc @@ -39,13 +39,15 @@ constexpr char kDummyTestCalculatorName[] = "DummyTestCalculator"; CalculatorGraphConfig::Node CreateNodeConfig( const std::string& raw_node_config) { CalculatorGraphConfig::Node node_config; - QCHECK(proto2::TextFormat::ParseFromString(raw_node_config, &node_config)); + QCHECK(google::protobuf::TextFormat::ParseFromString(raw_node_config, + &node_config)); return node_config; } CalculatorGraphConfig CreateGraphConfig(const std::string& raw_graph_config) { CalculatorGraphConfig graph_config; - QCHECK(proto2::TextFormat::ParseFromString(raw_graph_config, &graph_config)); + QCHECK(google::protobuf::TextFormat::ParseFromString(raw_graph_config, + &graph_config)); return graph_config; } @@ -1167,7 +1169,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) { TEST(GraphProfilerTest, ParallelReads) { // A graph that processes a certain number of packets before finishing. CalculatorGraphConfig config; - QCHECK(proto2::TextFormat::ParseFromString(R"( + QCHECK(google::protobuf::TextFormat::ParseFromString(R"( profiler_config { enable_profiler: true } @@ -1189,7 +1191,7 @@ TEST(GraphProfilerTest, ParallelReads) { } output_stream: "OUT:0:the_integers" )", - &config)); + &config)); // Start running the graph on its own threads. absl::Mutex out_1_mutex; @@ -1246,7 +1248,7 @@ std::set GetCalculatorNames(const CalculatorGraphConfig& config) { TEST(GraphProfilerTest, CalculatorProfileFilter) { CalculatorGraphConfig config; - QCHECK(proto2::TextFormat::ParseFromString(R"( + QCHECK(google::protobuf::TextFormat::ParseFromString(R"( profiler_config { enable_profiler: true } @@ -1268,7 +1270,7 @@ TEST(GraphProfilerTest, CalculatorProfileFilter) { } output_stream: "OUT:0:the_integers" )", - &config)); + &config)); std::set expected_names; expected_names = {"RangeCalculator", "PassThroughCalculator"}; @@ -1295,7 +1297,7 @@ TEST(GraphProfilerTest, CalculatorProfileFilter) { TEST(GraphProfilerTest, CaptureProfilePopulateConfig) { CalculatorGraphConfig config; - QCHECK(proto2::TextFormat::ParseFromString(R"( + QCHECK(google::protobuf::TextFormat::ParseFromString(R"( profiler_config { enable_profiler: true trace_enabled: true @@ -1310,7 +1312,7 @@ TEST(GraphProfilerTest, CaptureProfilePopulateConfig) { input_stream: "input_stream" } )", - &config)); + &config)); CalculatorGraph graph; MP_ASSERT_OK(graph.Initialize(config)); GraphProfile profile; diff --git a/mediapipe/framework/tool/options_lib_template.cc b/mediapipe/framework/tool/options_lib_template.cc index 21a5db10f..4861132a2 100644 --- a/mediapipe/framework/tool/options_lib_template.cc +++ b/mediapipe/framework/tool/options_lib_template.cc @@ -28,7 +28,7 @@ constexpr char kDescriptorContents[] = mediapipe::FieldData ReadFileDescriptorSet(const std::string& pb) { mediapipe::FieldData result; *result.mutable_message_value()->mutable_type_url() = - "proto2.FileDescriptorSet"; + "google::protobuf.FileDescriptorSet"; *result.mutable_message_value()->mutable_value() = pb; // Force linking of the generated options protobuf. diff --git a/mediapipe/framework/tool/options_registry.cc b/mediapipe/framework/tool/options_registry.cc index f6858be0a..07cc65a95 100644 --- a/mediapipe/framework/tool/options_registry.cc +++ b/mediapipe/framework/tool/options_registry.cc @@ -66,26 +66,28 @@ std::string GetFieldString(const FieldData& message_data, void RegisterDescriptorProtos( absl::flat_hash_map& result) { std::vector descriptors = { - {"proto2.FileDescriptorSet", + {"google::protobuf.FileDescriptorSet", { - {"file", 1, FieldType::TYPE_MESSAGE, "proto2.FileDescriptorProto"}, + {"file", 1, FieldType::TYPE_MESSAGE, + "google::protobuf.FileDescriptorProto"}, }}, - {"proto2.FileDescriptorProto", + {"google::protobuf.FileDescriptorProto", { {"package", 2, FieldType::TYPE_STRING, ""}, {"message_type", 4, FieldType::TYPE_MESSAGE, - "proto2.DescriptorProto"}, + "google::protobuf.DescriptorProto"}, }}, - {"proto2.DescriptorProto", + {"google::protobuf.DescriptorProto", { {"name", 1, FieldType::TYPE_STRING, ""}, - {"field", 2, FieldType::TYPE_MESSAGE, "proto2.FieldDescriptorProto"}, + {"field", 2, FieldType::TYPE_MESSAGE, + "google::protobuf.FieldDescriptorProto"}, {"extension", 6, FieldType::TYPE_MESSAGE, - "proto2.FieldDescriptorProto"}, + "google::protobuf.FieldDescriptorProto"}, {"nested_type", 3, FieldType::TYPE_MESSAGE, - "proto2.DescriptorProto"}, + "google::protobuf.DescriptorProto"}, }}, - {"proto2.FieldDescriptorProto", + {"google::protobuf.FieldDescriptorProto", { {"name", 1, FieldType::TYPE_STRING, ""}, {"number", 3, FieldType::TYPE_INT32, ""}, @@ -140,7 +142,7 @@ void OptionsRegistry::Register(const FieldData& message_type, const Descriptor* OptionsRegistry::GetProtobufDescriptor( const std::string& type_name) { - if (descriptors().count("proto2.DescriptorProto") == 0) { + if (descriptors().count("google::protobuf.DescriptorProto") == 0) { RegisterDescriptorProtos(descriptors()); } absl::ReaderMutexLock lock(&mutex()); diff --git a/mediapipe/framework/tool/options_registry.h b/mediapipe/framework/tool/options_registry.h index b843b113a..3b2d2be89 100644 --- a/mediapipe/framework/tool/options_registry.h +++ b/mediapipe/framework/tool/options_registry.h @@ -28,7 +28,7 @@ class OptionsRegistry { // Finds the descriptor for a protobuf. static const Descriptor* GetProtobufDescriptor(const std::string& type_name); - // Returns all known proto2 extensions to a type. + // Returns all known google::protobuf extensions to a type. static void FindAllExtensions(absl::string_view extendee, std::vector* result);