Internal change

PiperOrigin-RevId: 522255364
This commit is contained in:
MediaPipe Team 2023-04-05 23:23:29 -07:00 committed by Copybara-Service
parent 12ecc8139f
commit 56552dbfb5
5 changed files with 30 additions and 30 deletions

View File

@ -679,7 +679,7 @@ REGISTER_CALCULATOR(BoundToPacketCalculator);
// A Calculator that produces packets at timestamps beyond the input timestamp. // A Calculator that produces packets at timestamps beyond the input timestamp.
class FuturePacketCalculator : public CalculatorBase { class FuturePacketCalculator : public CalculatorBase {
public: public:
static constexpr int64 kOutputFutureMicros = 3; static constexpr int64_t kOutputFutureMicros = 3;
static absl::Status GetContract(CalculatorContract* cc) { static absl::Status GetContract(CalculatorContract* cc) {
cc->Inputs().Index(0).Set<int>(); cc->Inputs().Index(0).Set<int>();

View File

@ -188,21 +188,21 @@ class Uint64PacketGenerator : public PacketGenerator {
static absl::Status FillExpectations( static absl::Status FillExpectations(
const PacketGeneratorOptions& extendable_options, const PacketGeneratorOptions& extendable_options,
PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) { PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) {
output_side_packets->Index(0).Set<uint64>(); output_side_packets->Index(0).Set<uint64_t>();
return absl::OkStatus(); return absl::OkStatus();
} }
static absl::Status Generate(const PacketGeneratorOptions& extendable_options, static absl::Status Generate(const PacketGeneratorOptions& extendable_options,
const PacketSet& input_side_packets, const PacketSet& input_side_packets,
PacketSet* output_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(); return absl::OkStatus();
} }
}; };
REGISTER_PACKET_GENERATOR(Uint64PacketGenerator); REGISTER_PACKET_GENERATOR(Uint64PacketGenerator);
TEST(CalculatorGraph, OutputSidePacketInProcess) { TEST(CalculatorGraph, OutputSidePacketInProcess) {
const int64 offset = 100; const int64_t offset = 100;
CalculatorGraphConfig config = CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb( mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset" input_stream: "offset"
@ -400,7 +400,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) {
} }
TEST(CalculatorGraph, OutputSidePacketAlreadySet) { TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
const int64 offset = 100; const int64_t offset = 100;
CalculatorGraphConfig config = CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb( mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset" input_stream: "offset"
@ -427,7 +427,7 @@ TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
} }
TEST(CalculatorGraph, OutputSidePacketWithTimestamp) { TEST(CalculatorGraph, OutputSidePacketWithTimestamp) {
const int64 offset = 100; const int64_t offset = 100;
CalculatorGraphConfig config = CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb( mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset" input_stream: "offset"
@ -716,7 +716,7 @@ TEST(CalculatorGraph, GetOutputSidePacket) {
// Run the graph twice. // Run the graph twice.
int max_count = 100; int max_count = 100;
std::map<std::string, Packet> extra_side_packets; std::map<std::string, Packet> extra_side_packets;
extra_side_packets.insert({"input_uint64", MakePacket<uint64>(1123)}); extra_side_packets.insert({"input_uint64", MakePacket<uint64_t>(1123)});
for (int run = 0; run < 1; ++run) { for (int run = 0; run < 1; ++run) {
MP_ASSERT_OK(graph.StartRun(extra_side_packets)); MP_ASSERT_OK(graph.StartRun(extra_side_packets));
status_or_packet = graph.GetOutputSidePacket("output_uint32_pair"); status_or_packet = graph.GetOutputSidePacket("output_uint32_pair");

View File

@ -439,7 +439,7 @@ class GlobalCountSourceCalculator : public CalculatorBase {
++local_count_; ++local_count_;
} }
int64 local_count_ = 0; int64_t local_count_ = 0;
}; };
const int GlobalCountSourceCalculator::kNumOutputPackets = 5; const int GlobalCountSourceCalculator::kNumOutputPackets = 5;
REGISTER_CALCULATOR(GlobalCountSourceCalculator); REGISTER_CALCULATOR(GlobalCountSourceCalculator);
@ -765,7 +765,7 @@ class TypedStatusHandler : public StatusHandler {
} }
}; };
typedef TypedStatusHandler<std::string> StringStatusHandler; typedef TypedStatusHandler<std::string> StringStatusHandler;
typedef TypedStatusHandler<uint32> Uint32StatusHandler; typedef TypedStatusHandler<uint32_t> Uint32StatusHandler;
REGISTER_STATUS_HANDLER(StringStatusHandler); REGISTER_STATUS_HANDLER(StringStatusHandler);
REGISTER_STATUS_HANDLER(Uint32StatusHandler); REGISTER_STATUS_HANDLER(Uint32StatusHandler);
@ -1398,9 +1398,9 @@ void RunComprehensiveTest(CalculatorGraph* graph,
MP_ASSERT_OK(graph->Initialize(proto)); MP_ASSERT_OK(graph->Initialize(proto));
std::map<std::string, Packet> extra_side_packets; std::map<std::string, Packet> 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) { 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 // 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 // Verify that the graph can still run (but not successfully) when
// one of the nodes is caused to fail. // one of the nodes is caused to fail.
extra_side_packets.clear(); 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) { 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_sum_packet = Packet();
dumped_final_stddev_packet = Packet(); dumped_final_stddev_packet = Packet();
@ -1579,14 +1579,14 @@ class Uint64PacketGenerator : public PacketGenerator {
static absl::Status FillExpectations( static absl::Status FillExpectations(
const PacketGeneratorOptions& extendable_options, const PacketGeneratorOptions& extendable_options,
PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) { PacketTypeSet* input_side_packets, PacketTypeSet* output_side_packets) {
output_side_packets->Index(0).Set<uint64>(); output_side_packets->Index(0).Set<uint64_t>();
return absl::OkStatus(); return absl::OkStatus();
} }
static absl::Status Generate(const PacketGeneratorOptions& extendable_options, static absl::Status Generate(const PacketGeneratorOptions& extendable_options,
const PacketSet& input_side_packets, const PacketSet& input_side_packets,
PacketSet* output_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(); return absl::OkStatus();
} }
}; };
@ -1759,7 +1759,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
)pb"); )pb");
MP_ASSERT_OK(graph->Initialize(config)); MP_ASSERT_OK(graph->Initialize(config));
Packet extra_string = Adopt(new std::string("foo")); 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( MP_EXPECT_OK(
graph->Run({{"extra_string", extra_string}, {"a_uint64", a_uint64}})); graph->Run({{"extra_string", extra_string}, {"a_uint64", a_uint64}}));
@ -1789,7 +1789,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
testing::HasSubstr("string"), testing::HasSubstr("string"),
// Expected type. // Expected type.
testing::HasSubstr( testing::HasSubstr(
MediaPipeTypeStringOrDemangled<uint32>()))); MediaPipeTypeStringOrDemangled<uint32_t>())));
// Should fail verification when the type of a to-be-generated packet is // 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 // wrong. The added handler now expects a string but will receive the uint32
@ -1802,12 +1802,12 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
status = graph->Initialize(config); status = graph->Initialize(config);
EXPECT_THAT(status.message(), EXPECT_THAT(status.message(),
testing::AllOf( testing::AllOf(testing::HasSubstr("StringStatusHandler"),
testing::HasSubstr("StringStatusHandler"),
// The problematic input side packet. // The problematic input side packet.
testing::HasSubstr("generated_by_generator"), testing::HasSubstr("generated_by_generator"),
// Actual type. // Actual type.
testing::HasSubstr(MediaPipeTypeStringOrDemangled<uint32>()), testing::HasSubstr(
MediaPipeTypeStringOrDemangled<uint32_t>()),
// Expected type. // Expected type.
testing::HasSubstr("string"))); testing::HasSubstr("string")));
} }

View File

@ -216,7 +216,7 @@ mediapipe::Counter* CalculatorRunner::GetCounter(const std::string& name) {
return graph_->GetCounterFactory()->GetCounter(name); return graph_->GetCounterFactory()->GetCounter(name);
} }
std::map<std::string, int64> CalculatorRunner::GetCountersValues() { std::map<std::string, int64_t> CalculatorRunner::GetCountersValues() {
return graph_->GetCounterFactory()->GetCounterSet()->GetCountersValues(); return graph_->GetCounterFactory()->GetCounterSet()->GetCountersValues();
} }

View File

@ -39,14 +39,14 @@ class BasicCounter : public Counter {
value_ += amount; value_ += amount;
} }
int64 Get() ABSL_LOCKS_EXCLUDED(mu_) override { int64_t Get() ABSL_LOCKS_EXCLUDED(mu_) override {
absl::ReaderMutexLock lock(&mu_); absl::ReaderMutexLock lock(&mu_);
return value_; return value_;
} }
private: private:
absl::Mutex mu_; absl::Mutex mu_;
int64 value_ ABSL_GUARDED_BY(mu_); int64_t value_ ABSL_GUARDED_BY(mu_);
}; };
} // namespace } // namespace
@ -73,10 +73,10 @@ Counter* CounterSet::Get(const std::string& name) ABSL_LOCKS_EXCLUDED(mu_) {
return counters_[name].get(); return counters_[name].get();
} }
std::map<std::string, int64> CounterSet::GetCountersValues() std::map<std::string, int64_t> CounterSet::GetCountersValues()
ABSL_LOCKS_EXCLUDED(mu_) { ABSL_LOCKS_EXCLUDED(mu_) {
absl::ReaderMutexLock lock(&mu_); absl::ReaderMutexLock lock(&mu_);
std::map<std::string, int64> result; std::map<std::string, int64_t> result;
for (const auto& it : counters_) { for (const auto& it : counters_) {
result[it.first] = it.second->Get(); result[it.first] = it.second->Get();
} }