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.
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<int>();

View File

@ -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<uint64>();
output_side_packets->Index(0).Set<uint64_t>();
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<CalculatorGraphConfig>(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<CalculatorGraphConfig>(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<CalculatorGraphConfig>(R"pb(
input_stream: "offset"
@ -716,7 +716,7 @@ TEST(CalculatorGraph, GetOutputSidePacket) {
// Run the graph twice.
int max_count = 100;
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) {
MP_ASSERT_OK(graph.StartRun(extra_side_packets));
status_or_packet = graph.GetOutputSidePacket("output_uint32_pair");

View File

@ -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<std::string> StringStatusHandler;
typedef TypedStatusHandler<uint32> Uint32StatusHandler;
typedef TypedStatusHandler<uint32_t> 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<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) {
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<uint64>();
output_side_packets->Index(0).Set<uint64_t>();
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<uint32>())));
MediaPipeTypeStringOrDemangled<uint32_t>())));
// 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<uint32>()),
// 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<uint32_t>()),
// Expected type.
testing::HasSubstr("string")));
}
TEST(CalculatorGraph, GenerateInInitialize) {

View File

@ -216,7 +216,7 @@ mediapipe::Counter* CalculatorRunner::GetCounter(const std::string& 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();
}

View File

@ -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<std::string, int64> CounterSet::GetCountersValues()
std::map<std::string, int64_t> CounterSet::GetCountersValues()
ABSL_LOCKS_EXCLUDED(mu_) {
absl::ReaderMutexLock lock(&mu_);
std::map<std::string, int64> result;
std::map<std::string, int64_t> result;
for (const auto& it : counters_) {
result[it.first] = it.second->Get();
}