From 56552dbfb5818b6926d5b1c23f1f0e718a624623 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Wed, 5 Apr 2023 23:23:29 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 522255364 --- .../framework/calculator_graph_bounds_test.cc | 2 +- .../calculator_graph_side_packet_test.cc | 12 +++---- mediapipe/framework/calculator_graph_test.cc | 36 +++++++++---------- mediapipe/framework/calculator_runner.cc | 2 +- mediapipe/framework/counter_factory.cc | 8 ++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mediapipe/framework/calculator_graph_bounds_test.cc b/mediapipe/framework/calculator_graph_bounds_test.cc index d149337cc..81ce9902c 100644 --- a/mediapipe/framework/calculator_graph_bounds_test.cc +++ b/mediapipe/framework/calculator_graph_bounds_test.cc @@ -679,7 +679,7 @@ REGISTER_CALCULATOR(BoundToPacketCalculator); // A Calculator that produces packets at timestamps beyond the input timestamp. class FuturePacketCalculator : public CalculatorBase { public: - static constexpr int64 kOutputFutureMicros = 3; + static constexpr int64_t kOutputFutureMicros = 3; static absl::Status GetContract(CalculatorContract* cc) { cc->Inputs().Index(0).Set(); diff --git a/mediapipe/framework/calculator_graph_side_packet_test.cc b/mediapipe/framework/calculator_graph_side_packet_test.cc index 57fcff866..a9567c805 100644 --- a/mediapipe/framework/calculator_graph_side_packet_test.cc +++ b/mediapipe/framework/calculator_graph_side_packet_test.cc @@ -188,21 +188,21 @@ class Uint64PacketGenerator : public PacketGenerator { static absl::Status FillExpectations( const PacketGeneratorOptions& extendable_options, PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) { - output_side_packets->Index(0).Set(); + output_side_packets->Index(0).Set(); return absl::OkStatus(); } static absl::Status Generate(const PacketGeneratorOptions& extendable_options, const PacketSet& input_side_packets, PacketSet* output_side_packets) { - output_side_packets->Index(0) = Adopt(new uint64(15LL << 32 | 5)); + output_side_packets->Index(0) = Adopt(new uint64_t(15LL << 32 | 5)); return absl::OkStatus(); } }; REGISTER_PACKET_GENERATOR(Uint64PacketGenerator); TEST(CalculatorGraph, OutputSidePacketInProcess) { - const int64 offset = 100; + const int64_t offset = 100; CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie(R"pb( input_stream: "offset" @@ -400,7 +400,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) { } TEST(CalculatorGraph, OutputSidePacketAlreadySet) { - const int64 offset = 100; + const int64_t offset = 100; CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie(R"pb( input_stream: "offset" @@ -427,7 +427,7 @@ TEST(CalculatorGraph, OutputSidePacketAlreadySet) { } TEST(CalculatorGraph, OutputSidePacketWithTimestamp) { - const int64 offset = 100; + const int64_t offset = 100; CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie(R"pb( input_stream: "offset" @@ -716,7 +716,7 @@ TEST(CalculatorGraph, GetOutputSidePacket) { // Run the graph twice. int max_count = 100; std::map extra_side_packets; - extra_side_packets.insert({"input_uint64", MakePacket(1123)}); + extra_side_packets.insert({"input_uint64", MakePacket(1123)}); for (int run = 0; run < 1; ++run) { MP_ASSERT_OK(graph.StartRun(extra_side_packets)); status_or_packet = graph.GetOutputSidePacket("output_uint32_pair"); diff --git a/mediapipe/framework/calculator_graph_test.cc b/mediapipe/framework/calculator_graph_test.cc index 6ca206ab1..2e7d99ef6 100644 --- a/mediapipe/framework/calculator_graph_test.cc +++ b/mediapipe/framework/calculator_graph_test.cc @@ -439,7 +439,7 @@ class GlobalCountSourceCalculator : public CalculatorBase { ++local_count_; } - int64 local_count_ = 0; + int64_t local_count_ = 0; }; const int GlobalCountSourceCalculator::kNumOutputPackets = 5; REGISTER_CALCULATOR(GlobalCountSourceCalculator); @@ -765,7 +765,7 @@ class TypedStatusHandler : public StatusHandler { } }; typedef TypedStatusHandler StringStatusHandler; -typedef TypedStatusHandler Uint32StatusHandler; +typedef TypedStatusHandler Uint32StatusHandler; REGISTER_STATUS_HANDLER(StringStatusHandler); REGISTER_STATUS_HANDLER(Uint32StatusHandler); @@ -1398,9 +1398,9 @@ void RunComprehensiveTest(CalculatorGraph* graph, MP_ASSERT_OK(graph->Initialize(proto)); std::map extra_side_packets; - extra_side_packets.emplace("node_3", Adopt(new uint64((15LL << 32) | 3))); + extra_side_packets.emplace("node_3", Adopt(new uint64_t((15LL << 32) | 3))); if (define_node_5) { - extra_side_packets.emplace("node_5", Adopt(new uint64((15LL << 32) | 5))); + extra_side_packets.emplace("node_5", Adopt(new uint64_t((15LL << 32) | 5))); } // Call graph->Run() several times, to make sure that the appropriate @@ -1452,9 +1452,9 @@ void RunComprehensiveTest(CalculatorGraph* graph, // Verify that the graph can still run (but not successfully) when // one of the nodes is caused to fail. extra_side_packets.clear(); - extra_side_packets.emplace("node_3", Adopt(new uint64((15LL << 32) | 0))); + extra_side_packets.emplace("node_3", Adopt(new uint64_t((15LL << 32) | 0))); if (define_node_5) { - extra_side_packets.emplace("node_5", Adopt(new uint64((15LL << 32) | 5))); + extra_side_packets.emplace("node_5", Adopt(new uint64_t((15LL << 32) | 5))); } dumped_final_sum_packet = Packet(); dumped_final_stddev_packet = Packet(); @@ -1579,14 +1579,14 @@ class Uint64PacketGenerator : public PacketGenerator { static absl::Status FillExpectations( const PacketGeneratorOptions& extendable_options, PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) { - output_side_packets->Index(0).Set(); + output_side_packets->Index(0).Set(); return absl::OkStatus(); } static absl::Status Generate(const PacketGeneratorOptions& extendable_options, const PacketSet& input_side_packets, PacketSet* output_side_packets) { - output_side_packets->Index(0) = Adopt(new uint64(15LL << 32 | 5)); + output_side_packets->Index(0) = Adopt(new uint64_t(15LL << 32 | 5)); return absl::OkStatus(); } }; @@ -1759,7 +1759,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) { )pb"); MP_ASSERT_OK(graph->Initialize(config)); Packet extra_string = Adopt(new std::string("foo")); - Packet a_uint64 = Adopt(new uint64(0)); + Packet a_uint64 = Adopt(new uint64_t(0)); MP_EXPECT_OK( graph->Run({{"extra_string", extra_string}, {"a_uint64", a_uint64}})); @@ -1789,7 +1789,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) { testing::HasSubstr("string"), // Expected type. testing::HasSubstr( - MediaPipeTypeStringOrDemangled()))); + MediaPipeTypeStringOrDemangled()))); // Should fail verification when the type of a to-be-generated packet is // wrong. The added handler now expects a string but will receive the uint32 @@ -1802,14 +1802,14 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) { status = graph->Initialize(config); EXPECT_THAT(status.message(), - testing::AllOf( - testing::HasSubstr("StringStatusHandler"), - // The problematic input side packet. - testing::HasSubstr("generated_by_generator"), - // Actual type. - testing::HasSubstr(MediaPipeTypeStringOrDemangled()), - // Expected type. - testing::HasSubstr("string"))); + testing::AllOf(testing::HasSubstr("StringStatusHandler"), + // The problematic input side packet. + testing::HasSubstr("generated_by_generator"), + // Actual type. + testing::HasSubstr( + MediaPipeTypeStringOrDemangled()), + // Expected type. + testing::HasSubstr("string"))); } TEST(CalculatorGraph, GenerateInInitialize) { diff --git a/mediapipe/framework/calculator_runner.cc b/mediapipe/framework/calculator_runner.cc index 833797483..1bd3211ed 100644 --- a/mediapipe/framework/calculator_runner.cc +++ b/mediapipe/framework/calculator_runner.cc @@ -216,7 +216,7 @@ mediapipe::Counter* CalculatorRunner::GetCounter(const std::string& name) { return graph_->GetCounterFactory()->GetCounter(name); } -std::map CalculatorRunner::GetCountersValues() { +std::map CalculatorRunner::GetCountersValues() { return graph_->GetCounterFactory()->GetCounterSet()->GetCountersValues(); } diff --git a/mediapipe/framework/counter_factory.cc b/mediapipe/framework/counter_factory.cc index 94a6a4213..895b44ea6 100644 --- a/mediapipe/framework/counter_factory.cc +++ b/mediapipe/framework/counter_factory.cc @@ -39,14 +39,14 @@ class BasicCounter : public Counter { value_ += amount; } - int64 Get() ABSL_LOCKS_EXCLUDED(mu_) override { + int64_t Get() ABSL_LOCKS_EXCLUDED(mu_) override { absl::ReaderMutexLock lock(&mu_); return value_; } private: absl::Mutex mu_; - int64 value_ ABSL_GUARDED_BY(mu_); + int64_t value_ ABSL_GUARDED_BY(mu_); }; } // namespace @@ -73,10 +73,10 @@ Counter* CounterSet::Get(const std::string& name) ABSL_LOCKS_EXCLUDED(mu_) { return counters_[name].get(); } -std::map CounterSet::GetCountersValues() +std::map CounterSet::GetCountersValues() ABSL_LOCKS_EXCLUDED(mu_) { absl::ReaderMutexLock lock(&mu_); - std::map result; + std::map result; for (const auto& it : counters_) { result[it.first] = it.second->Get(); }