Project import generated by Copybara.
GitOrigin-RevId: 6a704ded0bf489614797082e7e7cda1068477ef5
This commit is contained in:
@@ -27,7 +27,7 @@ TEST(BuilderTest, BuildGraph) {
|
||||
bar.Out("OUT").SetName("out") >> graph.Out("OUT");
|
||||
|
||||
CalculatorGraphConfig expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:base"
|
||||
input_side_packet: "SIDE:side"
|
||||
output_stream: "OUT:out"
|
||||
@@ -42,7 +42,7 @@ TEST(BuilderTest, BuildGraph) {
|
||||
input_stream: "IN:__stream_0"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ TEST(BuilderTest, FanOut) {
|
||||
adder.Out("OUT").SetName("out") >> graph.Out("OUT");
|
||||
|
||||
CalculatorGraphConfig expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:base"
|
||||
output_stream: "OUT:out"
|
||||
node {
|
||||
@@ -106,7 +106,7 @@ TEST(BuilderTest, FanOut) {
|
||||
input_stream: "IN:1:__stream_0"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ TEST(BuilderTest, TypedMultiple) {
|
||||
adder.Out(MPP_TAG("OUT")).SetName("out") >> graph.Out("OUT");
|
||||
|
||||
CalculatorGraphConfig expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:base"
|
||||
output_stream: "OUT:out"
|
||||
node {
|
||||
@@ -134,7 +134,7 @@ TEST(BuilderTest, TypedMultiple) {
|
||||
input_stream: "IN:1:__stream_0"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ TEST(BuilderTest, PacketGenerator) {
|
||||
generator.SideOut("OUT") >> graph.SideOut("OUT");
|
||||
|
||||
CalculatorGraphConfig expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "IN:__side_packet_0"
|
||||
output_side_packet: "OUT:__side_packet_1"
|
||||
packet_generator {
|
||||
@@ -153,7 +153,7 @@ TEST(BuilderTest, PacketGenerator) {
|
||||
input_side_packet: "IN:__side_packet_0"
|
||||
output_side_packet: "OUT:__side_packet_1"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ TEST(BuilderTest, EmptyTag) {
|
||||
foo.Out("")[1].SetName("y") >> graph.Out("TWO");
|
||||
|
||||
CalculatorGraphConfig expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "A:a"
|
||||
input_stream: "B:b"
|
||||
input_stream: "C:c"
|
||||
@@ -181,7 +181,7 @@ TEST(BuilderTest, EmptyTag) {
|
||||
output_stream: "x"
|
||||
output_stream: "y"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
|
||||
}
|
||||
|
||||
|
||||
@@ -132,12 +132,12 @@ TEST(NodeTest, GetContract) {
|
||||
// with what you have in the graph, then you let the calculator fill it in
|
||||
// with what it expects, and then you see if they match.
|
||||
const CalculatorGraphConfig::Node node_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
|
||||
calculator: "Foo"
|
||||
input_stream: "BASE:base"
|
||||
input_stream: "SCALE:scale"
|
||||
output_stream: "OUT:out"
|
||||
)");
|
||||
)pb");
|
||||
mediapipe::CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node_config));
|
||||
MP_EXPECT_OK(Foo::Contract::GetContract(&contract));
|
||||
@@ -147,13 +147,13 @@ TEST(NodeTest, GetContract) {
|
||||
|
||||
TEST(NodeTest, GetContractMulti) {
|
||||
const CalculatorGraphConfig::Node node_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
|
||||
calculator: "Baz"
|
||||
input_stream: "DATA:0:b"
|
||||
input_stream: "DATA:1:c"
|
||||
output_stream: "DATA:0:d"
|
||||
output_stream: "DATA:1:e"
|
||||
)");
|
||||
)pb");
|
||||
mediapipe::CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node_config));
|
||||
MP_EXPECT_OK(Baz::Contract::GetContract(&contract));
|
||||
@@ -204,7 +204,7 @@ TEST(NodeTest, RunInGraph5) { RunFooCalculatorInGraph("Foo5"); }
|
||||
|
||||
TEST(NodeTest, OptionalStream) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "base"
|
||||
input_side_packet: "bias"
|
||||
output_stream: "out"
|
||||
@@ -214,7 +214,7 @@ TEST(NodeTest, OptionalStream) {
|
||||
input_side_packet: "BIAS:bias"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<mediapipe::Packet> out_packets;
|
||||
tool::AddVectorSink("out", &config, &out_packets);
|
||||
mediapipe::CalculatorGraph graph;
|
||||
@@ -229,7 +229,7 @@ TEST(NodeTest, OptionalStream) {
|
||||
|
||||
TEST(NodeTest, DynamicTypes) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
output_stream: "out"
|
||||
node {
|
||||
@@ -242,7 +242,7 @@ TEST(NodeTest, DynamicTypes) {
|
||||
input_stream: "IN:bar"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<mediapipe::Packet> out_packets;
|
||||
tool::AddVectorSink("out", &config, &out_packets);
|
||||
mediapipe::CalculatorGraph graph;
|
||||
@@ -257,7 +257,7 @@ TEST(NodeTest, DynamicTypes) {
|
||||
|
||||
TEST(NodeTest, MultiPort) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in0"
|
||||
input_stream: "in1"
|
||||
output_stream: "out0"
|
||||
@@ -279,7 +279,7 @@ TEST(NodeTest, MultiPort) {
|
||||
input_stream: "IN:baz1"
|
||||
output_stream: "OUT:out1"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<mediapipe::Packet> out0_packets;
|
||||
std::vector<mediapipe::Packet> out1_packets;
|
||||
tool::AddVectorSink("out0", &config, &out0_packets);
|
||||
@@ -325,7 +325,7 @@ MEDIAPIPE_REGISTER_NODE(SideFallback);
|
||||
|
||||
TEST(NodeTest, SideFallbackWithStream) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
input_stream: "factor"
|
||||
output_stream: "out"
|
||||
@@ -335,7 +335,7 @@ TEST(NodeTest, SideFallbackWithStream) {
|
||||
input_stream: "FACTOR:factor"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<int> outputs;
|
||||
mediapipe::CalculatorGraph graph;
|
||||
MP_EXPECT_OK(graph.Initialize(config, {}));
|
||||
@@ -356,7 +356,7 @@ TEST(NodeTest, SideFallbackWithStream) {
|
||||
|
||||
TEST(NodeTest, SideFallbackWithSide) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
input_side_packet: "factor"
|
||||
output_stream: "out"
|
||||
@@ -366,7 +366,7 @@ TEST(NodeTest, SideFallbackWithSide) {
|
||||
input_side_packet: "FACTOR:factor"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<int> outputs;
|
||||
mediapipe::CalculatorGraph graph;
|
||||
MP_EXPECT_OK(graph.Initialize(config, {}));
|
||||
@@ -385,7 +385,7 @@ TEST(NodeTest, SideFallbackWithSide) {
|
||||
|
||||
TEST(NodeTest, SideFallbackWithNone) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
output_stream: "out"
|
||||
node {
|
||||
@@ -393,7 +393,7 @@ TEST(NodeTest, SideFallbackWithNone) {
|
||||
input_stream: "IN:in"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<int> outputs;
|
||||
mediapipe::CalculatorGraph graph;
|
||||
auto status = graph.Initialize(config, {});
|
||||
@@ -402,7 +402,7 @@ TEST(NodeTest, SideFallbackWithNone) {
|
||||
|
||||
TEST(NodeTest, SideFallbackWithBoth) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
input_stream: "factor"
|
||||
input_side_packet: "factor_side"
|
||||
@@ -414,7 +414,7 @@ TEST(NodeTest, SideFallbackWithBoth) {
|
||||
input_side_packet: "FACTOR:factor_side"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<int> outputs;
|
||||
mediapipe::CalculatorGraph graph;
|
||||
auto status = graph.Initialize(config, {});
|
||||
@@ -423,7 +423,7 @@ TEST(NodeTest, SideFallbackWithBoth) {
|
||||
|
||||
TEST(NodeTest, OneOf) {
|
||||
CalculatorGraphConfig config =
|
||||
::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
output_stream: "out"
|
||||
node {
|
||||
@@ -431,7 +431,7 @@ TEST(NodeTest, OneOf) {
|
||||
input_stream: "IN:in"
|
||||
output_stream: "OUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<mediapipe::Packet> out_packets;
|
||||
tool::AddVectorSink("out", &config, &out_packets);
|
||||
mediapipe::CalculatorGraph graph;
|
||||
@@ -484,7 +484,7 @@ MEDIAPIPE_REGISTER_NODE(ListIntPackets);
|
||||
|
||||
TEST(NodeTest, DefaultTimestampChange0) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "a"
|
||||
input_stream: "b"
|
||||
output_stream: "out"
|
||||
@@ -504,7 +504,7 @@ TEST(NodeTest, DefaultTimestampChange0) {
|
||||
input_stream: "INT:1:b"
|
||||
output_stream: "STR:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<mediapipe::Packet> out_packets;
|
||||
tool::AddVectorSink("out", &config, &out_packets);
|
||||
mediapipe::CalculatorGraph graph;
|
||||
@@ -541,7 +541,7 @@ MEDIAPIPE_REGISTER_NODE(ConsumerNode);
|
||||
|
||||
TEST(NodeTest, ConsumeInputs) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "int"
|
||||
input_stream: "any"
|
||||
input_stream: "num"
|
||||
@@ -551,7 +551,7 @@ TEST(NodeTest, ConsumeInputs) {
|
||||
input_stream: "ANY:any"
|
||||
input_stream: "NUM:num"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
mediapipe::CalculatorGraph graph;
|
||||
MP_EXPECT_OK(graph.Initialize(config, {}));
|
||||
MP_EXPECT_OK(graph.StartRun({}));
|
||||
|
||||
@@ -46,7 +46,7 @@ class FooBarImpl2 : public SubgraphImpl<FooBar2, FooBarImpl2> {
|
||||
TEST(SubgraphTest, SubgraphConfig) {
|
||||
CalculatorGraphConfig subgraph = FooBarImpl1().GetConfig({}).value();
|
||||
const CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:__stream_0"
|
||||
output_stream: "OUT:__stream_2"
|
||||
node {
|
||||
@@ -59,14 +59,14 @@ TEST(SubgraphTest, SubgraphConfig) {
|
||||
input_stream: "IN:__stream_1"
|
||||
output_stream: "OUT:__stream_2"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(subgraph, EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
TEST(SubgraphTest, TypedSubgraphConfig) {
|
||||
CalculatorGraphConfig subgraph = FooBarImpl2().GetConfig({}).value();
|
||||
const CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:__stream_0"
|
||||
output_stream: "OUT:__stream_2"
|
||||
node {
|
||||
@@ -79,7 +79,7 @@ TEST(SubgraphTest, TypedSubgraphConfig) {
|
||||
input_stream: "IN:__stream_1"
|
||||
output_stream: "OUT:__stream_2"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(subgraph, EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ TEST(SubgraphTest, ProtoApiConfig) {
|
||||
bar->add_output_stream("OUT:__stream_2");
|
||||
|
||||
const CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:__stream_0"
|
||||
output_stream: "OUT:__stream_2"
|
||||
node {
|
||||
@@ -110,13 +110,13 @@ TEST(SubgraphTest, ProtoApiConfig) {
|
||||
input_stream: "IN:__stream_1"
|
||||
output_stream: "OUT:__stream_2"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
EXPECT_THAT(graph, EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
TEST(SubgraphTest, ExpandSubgraphs) {
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "simple_source"
|
||||
calculator: "SomeSourceCalculator"
|
||||
@@ -127,9 +127,9 @@ TEST(SubgraphTest, ExpandSubgraphs) {
|
||||
input_stream: "IN:foo"
|
||||
output_stream: "OUT:output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
const CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "simple_source"
|
||||
calculator: "SomeSourceCalculator"
|
||||
@@ -147,7 +147,7 @@ TEST(SubgraphTest, ExpandSubgraphs) {
|
||||
input_stream: "IN:foobar____stream_1"
|
||||
output_stream: "OUT:output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace {
|
||||
|
||||
TEST(CalculatorContractTest, Calculator) {
|
||||
const CalculatorGraphConfig::Node node =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
|
||||
calculator: "MixtureOfExpertsFusionCalculator"
|
||||
input_stream: "FRAME:fdense_pca_moe_aggregated_detection"
|
||||
input_stream: "FNET:fnet_logreg_aggregated_detection"
|
||||
@@ -38,7 +38,7 @@ TEST(CalculatorContractTest, Calculator) {
|
||||
input_stream: "VIDEO:fdense_averaged_pca_moe_v2_detection"
|
||||
input_side_packet: "FUSION_MODEL:egraph_topical_packet_factory"
|
||||
output_stream: "egraph_topical_detection"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.Inputs().NumEntries(), 4);
|
||||
@@ -49,7 +49,7 @@ TEST(CalculatorContractTest, Calculator) {
|
||||
|
||||
TEST(CalculatorContractTest, CalculatorOptions) {
|
||||
const CalculatorGraphConfig::Node node =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
|
||||
calculator: "CalculatorTestCalculator"
|
||||
input_stream: "DATA:ycbcr_frames"
|
||||
input_stream: "VIDEO_HEADER:ycbcr_frames_prestream"
|
||||
@@ -57,7 +57,7 @@ TEST(CalculatorContractTest, CalculatorOptions) {
|
||||
output_stream: "VIDEO_HEADER:ycbcr_downsampled_prestream"
|
||||
options {
|
||||
[mediapipe.CalculatorContractTestOptions.ext] { test_field: 1.0 }
|
||||
})");
|
||||
})pb");
|
||||
CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
const auto& test_options =
|
||||
@@ -71,14 +71,14 @@ TEST(CalculatorContractTest, CalculatorOptions) {
|
||||
|
||||
TEST(CalculatorContractTest, PacketGenerator) {
|
||||
const PacketGeneratorConfig node =
|
||||
mediapipe::ParseTextProtoOrDie<PacketGeneratorConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<PacketGeneratorConfig>(R"pb(
|
||||
packet_generator: "DaredevilLabeledTimeSeriesGenerator"
|
||||
input_side_packet: "labeled_time_series"
|
||||
output_side_packet: "time_series_header"
|
||||
output_side_packet: "input_matrix"
|
||||
output_side_packet: "label_set"
|
||||
output_side_packet: "content_fingerprint"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1);
|
||||
@@ -87,11 +87,11 @@ TEST(CalculatorContractTest, PacketGenerator) {
|
||||
|
||||
TEST(CalculatorContractTest, StatusHandler) {
|
||||
const StatusHandlerConfig node =
|
||||
mediapipe::ParseTextProtoOrDie<StatusHandlerConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<StatusHandlerConfig>(R"pb(
|
||||
status_handler: "TaskInjectorStatusHandler"
|
||||
input_side_packet: "ROW:cid"
|
||||
input_side_packet: "SPEC:task_specification"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 2);
|
||||
|
||||
@@ -306,7 +306,7 @@ REGISTER_CALCULATOR(CustomBoundCalculator);
|
||||
TEST(CalculatorGraph, SetNextTimestampBoundPropagation) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
input_stream: 'gate'
|
||||
node {
|
||||
@@ -338,7 +338,7 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) {
|
||||
input_stream: 'merged'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
Timestamp timestamp = Timestamp(0);
|
||||
auto send_inputs = [&graph, ×tamp](int input, bool pass) {
|
||||
@@ -431,7 +431,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
|
||||
//
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in0_unfiltered'
|
||||
input_stream: 'in1_to_be_filtered'
|
||||
node {
|
||||
@@ -445,7 +445,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
|
||||
input_stream: 'in1_filtered'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("out", &config, &packet_dump);
|
||||
|
||||
@@ -503,7 +503,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
|
||||
|
||||
TEST(CalculatorGraph, PropagateBoundLoop) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'OutputAndBoundSourceCalculator'
|
||||
output_stream: 'integers'
|
||||
@@ -526,7 +526,7 @@ TEST(CalculatorGraph, PropagateBoundLoop) {
|
||||
input_stream: 'sum'
|
||||
output_stream: 'old_sum'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("sum", &config, &packet_dump);
|
||||
|
||||
@@ -549,7 +549,7 @@ TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) {
|
||||
// the sink calculator's input stream should report packet timestamp
|
||||
// mismatches.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'OutputAndBoundSourceCalculator'
|
||||
output_stream: 'integers'
|
||||
@@ -568,7 +568,7 @@ TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) {
|
||||
}
|
||||
}
|
||||
node { calculator: 'IntSinkCalculator' input_stream: 'output' }
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Run());
|
||||
@@ -581,7 +581,7 @@ TEST(CalculatorGraphBoundsTest, ImmediateHandlerBounds) {
|
||||
// The second PassthroughCalculator delivers an output packet whenever the
|
||||
// first PassThroughCalculator delivers a timestamp bound.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'input'
|
||||
node {
|
||||
calculator: 'CustomBoundCalculator'
|
||||
@@ -603,7 +603,7 @@ TEST(CalculatorGraphBoundsTest, ImmediateHandlerBounds) {
|
||||
output_stream: 'bounds_output'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
std::vector<Packet> output_packets;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
@@ -703,7 +703,7 @@ TEST(CalculatorGraphBoundsTest, OffsetBoundPropagation) {
|
||||
// The PassThroughCalculator delivers an output packet whenever the
|
||||
// OffsetBoundCalculator delivers a timestamp bound.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'input'
|
||||
node {
|
||||
calculator: 'OffsetBoundCalculator'
|
||||
@@ -717,7 +717,7 @@ TEST(CalculatorGraphBoundsTest, OffsetBoundPropagation) {
|
||||
output_stream: 'bounds_output'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
std::vector<Packet> output_packets;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
@@ -751,7 +751,7 @@ TEST(CalculatorGraphBoundsTest, BoundWithoutInputPackets) {
|
||||
// The BoundToPacketCalculator delivers an output packet whenever the
|
||||
// OffsetBoundCalculator delivers a timestamp bound.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'input'
|
||||
node {
|
||||
calculator: 'FuturePacketCalculator'
|
||||
@@ -768,7 +768,7 @@ TEST(CalculatorGraphBoundsTest, BoundWithoutInputPackets) {
|
||||
input_stream: 'bounds'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
std::vector<Packet> output_packets;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
@@ -809,7 +809,7 @@ TEST(CalculatorGraphBoundsTest, FixedSizeHandlerBounds) {
|
||||
// The PassthroughCalculator delivers an output packet whenever the
|
||||
// LambdaCalculator delivers a timestamp bound.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'input'
|
||||
input_side_packet: 'open_function'
|
||||
input_side_packet: 'process_function'
|
||||
@@ -830,7 +830,7 @@ TEST(CalculatorGraphBoundsTest, FixedSizeHandlerBounds) {
|
||||
output_stream: 'thinned_output'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
|
||||
// The task_semaphore counts the number of running tasks.
|
||||
@@ -951,7 +951,7 @@ TEST(CalculatorGraphBoundsTest, LastPacketCheck) {
|
||||
// packet or input stream close. The output "last_output" shows the
|
||||
// last packet, and "output" shows the timestamp bounds.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'input'
|
||||
output_stream: 'output'
|
||||
output_stream: 'last_output'
|
||||
@@ -972,7 +972,7 @@ TEST(CalculatorGraphBoundsTest, LastPacketCheck) {
|
||||
output_stream: 'output'
|
||||
output_stream: 'last_output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
std::vector<Packet> output_packets;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
|
||||
@@ -185,7 +185,7 @@ REGISTER_PACKET_GENERATOR(Uint64PacketGenerator);
|
||||
TEST(CalculatorGraph, OutputSidePacketInProcess) {
|
||||
const int64 offset = 100;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "offset"
|
||||
node {
|
||||
calculator: "OutputSidePacketInProcessCalculator"
|
||||
@@ -197,7 +197,7 @@ TEST(CalculatorGraph, OutputSidePacketInProcess) {
|
||||
output_stream: "output"
|
||||
input_side_packet: "offset"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
std::vector<Packet> output_packets;
|
||||
@@ -255,7 +255,7 @@ REGISTER_PACKET_GENERATOR(PassThroughGenerator);
|
||||
|
||||
TEST(CalculatorGraph, SharePacketGeneratorGraph) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'count1'
|
||||
@@ -296,7 +296,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) {
|
||||
input_side_packet: 'max_count4'
|
||||
output_side_packet: 'max_count5'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// At this point config is a standard config which specifies both
|
||||
// calculators and packet_factories/packet_genators. The following
|
||||
@@ -383,14 +383,14 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) {
|
||||
TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
|
||||
const int64 offset = 100;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "offset"
|
||||
node {
|
||||
calculator: "OutputSidePacketInProcessCalculator"
|
||||
input_stream: "offset"
|
||||
output_side_packet: "offset"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -410,14 +410,14 @@ TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
|
||||
TEST(CalculatorGraph, OutputSidePacketWithTimestamp) {
|
||||
const int64 offset = 100;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "offset"
|
||||
node {
|
||||
calculator: "OutputSidePacketWithTimestampCalculator"
|
||||
input_stream: "offset"
|
||||
output_side_packet: "offset"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -436,7 +436,7 @@ TEST(CalculatorGraph, OutputSidePacketWithTimestamp) {
|
||||
TEST(CalculatorGraph, OutputSidePacketConsumedBySourceNode) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "max_count"
|
||||
node {
|
||||
calculator: "OutputSidePacketInProcessCalculator"
|
||||
@@ -453,7 +453,7 @@ TEST(CalculatorGraph, OutputSidePacketConsumedBySourceNode) {
|
||||
input_stream: "count"
|
||||
output_stream: "output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
std::vector<Packet> output_packets;
|
||||
@@ -529,7 +529,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
|
||||
// Set num_threads to 1 to force sequential execution for deterministic
|
||||
// outputs.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
num_threads: 1
|
||||
node {
|
||||
calculator: "CountingSourceCalculator"
|
||||
@@ -563,7 +563,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
|
||||
input_side_packet: "INCREMENT:increment2"
|
||||
source_layer: 0
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(
|
||||
config, {{"max_count", MakePacket<int>(max_count)},
|
||||
@@ -577,7 +577,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
|
||||
// streams and no output streams.
|
||||
TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "IntegerOutputSidePacketCalculator"
|
||||
output_side_packet: "one"
|
||||
@@ -607,7 +607,7 @@ TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
|
||||
input_side_packet: "three"
|
||||
output_stream: "output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
std::vector<Packet> output_packets;
|
||||
@@ -624,7 +624,7 @@ TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
|
||||
|
||||
TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_packets"
|
||||
node {
|
||||
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
|
||||
@@ -636,7 +636,7 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
|
||||
input_side_packet: "num_of_packets"
|
||||
output_stream: "output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
std::vector<Packet> output_packets;
|
||||
@@ -665,7 +665,7 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
|
||||
|
||||
TEST(CalculatorGraph, GetOutputSidePacket) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_packets"
|
||||
node {
|
||||
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
|
||||
@@ -681,7 +681,7 @@ TEST(CalculatorGraph, GetOutputSidePacket) {
|
||||
input_side_packet: "input_uint64"
|
||||
output_side_packet: "output_uint32_pair"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
// Check a packet generated by the PacketGenerator, which is available after
|
||||
@@ -771,7 +771,7 @@ bool Equals(Packet p1, Packet p2) {
|
||||
|
||||
TEST(CalculatorGraph, OutputSidePacketCached) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "OutputSidePacketCachedCalculator"
|
||||
output_side_packet: "model"
|
||||
@@ -781,7 +781,7 @@ TEST(CalculatorGraph, OutputSidePacketCached) {
|
||||
input_side_packet: "model"
|
||||
output_stream: "output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
std::vector<Packet> output_packets;
|
||||
|
||||
@@ -1283,7 +1283,7 @@ class CurrentThreadExecutor : public Executor {
|
||||
// Returns a CalculatorGraphConfig used by tests.
|
||||
CalculatorGraphConfig GetConfig() {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
# The graph configuration. We list the nodes in an arbitrary (not
|
||||
# topologically-sorted) order to verify that CalculatorGraph can
|
||||
# handle such configurations.
|
||||
@@ -1385,7 +1385,7 @@ CalculatorGraphConfig GetConfig() {
|
||||
output_side_packet: "LOW:unused_low"
|
||||
output_side_packet: "PAIR:node_5_converted"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -1739,7 +1739,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
|
||||
// Status handlers with all inputs present should be OK.
|
||||
auto graph = absl::make_unique<CalculatorGraph>();
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
packet_generator {
|
||||
packet_generator: "StaticCounterStringGenerator"
|
||||
output_side_packet: "created_by_factory"
|
||||
@@ -1763,7 +1763,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
|
||||
status_handler: "StringStatusHandler"
|
||||
input_side_packet: "extra_string"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_ASSERT_OK(graph->Initialize(config));
|
||||
Packet extra_string = Adopt(new std::string("foo"));
|
||||
Packet a_uint64 = Adopt(new uint64(0));
|
||||
@@ -1823,7 +1823,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
|
||||
TEST(CalculatorGraph, GenerateInInitialize) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
packet_generator {
|
||||
packet_generator: "StaticCounterStringGenerator"
|
||||
input_side_packet: "created_by_factory"
|
||||
@@ -1852,7 +1852,7 @@ TEST(CalculatorGraph, GenerateInInitialize) {
|
||||
input_side_packet: "foo3"
|
||||
output_side_packet: "foo4"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
int initial_count = StaticCounterStringGenerator::NumPacketsGenerated();
|
||||
MP_ASSERT_OK(graph.Initialize(
|
||||
config,
|
||||
@@ -1903,7 +1903,7 @@ void ResetCounters(std::map<std::string, Packet>* input_side_packets) {
|
||||
TEST(CalculatorGraph, HandlersRun) {
|
||||
std::unique_ptr<CalculatorGraph> graph(new CalculatorGraph());
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
packet_generator {
|
||||
packet_generator: "FailingPacketGenerator"
|
||||
output_side_packet: "unavailable"
|
||||
@@ -1926,7 +1926,7 @@ TEST(CalculatorGraph, HandlersRun) {
|
||||
input_side_packet: "COUNTER2:unavailable_input_counter2"
|
||||
input_side_packet: "EXTRA:unavailable"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::map<std::string, Packet> input_side_packets(
|
||||
{{"unused_input", AdoptAsUniquePtr(new int(0))},
|
||||
{"no_input_counter1", AdoptAsUniquePtr(new int(0))},
|
||||
@@ -2073,14 +2073,14 @@ TEST(CalculatorGraph, HandlersRun) {
|
||||
TEST(CalculatorGraph, SetOffsetInProcess) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
node {
|
||||
calculator: 'SetOffsetInProcessCalculator'
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_EXPECT_OK(graph.StartRun({}));
|
||||
@@ -2095,7 +2095,7 @@ TEST(CalculatorGraph, SetOffsetInProcess) {
|
||||
TEST(CalculatorGraph, InputPacketLifetime) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
@@ -2107,7 +2107,7 @@ TEST(CalculatorGraph, InputPacketLifetime) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
LifetimeTracker tracker;
|
||||
Timestamp timestamp = Timestamp(0);
|
||||
@@ -2138,7 +2138,7 @@ TEST(CalculatorGraph, IfThenElse) {
|
||||
// of the two branches different.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
input_stream: 'select'
|
||||
node {
|
||||
@@ -2175,7 +2175,7 @@ TEST(CalculatorGraph, IfThenElse) {
|
||||
input_stream: 'SELECT:select'
|
||||
output_stream: 'OUTPUT:out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("out", &config, &packet_dump);
|
||||
|
||||
@@ -2281,7 +2281,7 @@ TEST(CalculatorGraph, IfThenElse2) {
|
||||
// of the two branches different.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
input_stream: 'select'
|
||||
node {
|
||||
@@ -2319,7 +2319,7 @@ TEST(CalculatorGraph, IfThenElse2) {
|
||||
output_stream: 'OUTPUT:out'
|
||||
input_stream_handler { input_stream_handler: 'MuxInputStreamHandler' }
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("out", &config, &packet_dump);
|
||||
|
||||
@@ -2402,7 +2402,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
|
||||
// the source node filled an input stream and the input stream changes from
|
||||
// being "full" to "not full".
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
num_threads: 1
|
||||
max_queue_size: 100
|
||||
node {
|
||||
@@ -2425,7 +2425,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
|
||||
input_stream: 'decimated_second_stream'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
@@ -2443,7 +2443,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
|
||||
// The scheduler should be able to run the graph from this initial state.
|
||||
TEST(CalculatorGraph, OutputPacketInOpen) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
max_queue_size: 1
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
@@ -2460,7 +2460,7 @@ TEST(CalculatorGraph, OutputPacketInOpen) {
|
||||
input_stream: 'delayed_integers'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("output", &config, &packet_dump);
|
||||
|
||||
@@ -2492,7 +2492,7 @@ TEST(CalculatorGraph, OutputPacketInOpen) {
|
||||
// The scheduler must schedule a throttled source node from the beginning.
|
||||
TEST(CalculatorGraph, OutputPacketInOpen2) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
max_queue_size: 1
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
@@ -2510,7 +2510,7 @@ TEST(CalculatorGraph, OutputPacketInOpen2) {
|
||||
input_stream: 'integers'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("output", &config, &packet_dump);
|
||||
|
||||
@@ -2541,7 +2541,7 @@ TEST(CalculatorGraph, OutputPacketInOpen2) {
|
||||
// upstream calculator outputs a packet in Open().
|
||||
TEST(CalculatorGraph, EmptyInputInOpen) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
max_queue_size: 1
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
@@ -2562,7 +2562,7 @@ TEST(CalculatorGraph, EmptyInputInOpen) {
|
||||
calculator: 'AssertEmptyInputInOpenCalculator'
|
||||
input_stream: 'integers'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
std::atomic<int> global_counter(1);
|
||||
std::map<std::string, Packet> input_side_packets;
|
||||
@@ -2576,7 +2576,7 @@ TEST(CalculatorGraph, EmptyInputInOpen) {
|
||||
// Test for b/33568859.
|
||||
TEST(CalculatorGraph, UnthrottleRespectsLayers) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
max_queue_size: 1
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
@@ -2596,7 +2596,7 @@ TEST(CalculatorGraph, UnthrottleRespectsLayers) {
|
||||
input_stream: 'integers1'
|
||||
output_stream: 'integers1passthrough'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
std::vector<Packet> layer0_packets;
|
||||
std::vector<Packet> layer1_packets;
|
||||
@@ -2642,7 +2642,7 @@ TEST(CalculatorGraph, UnthrottleRespectsLayers) {
|
||||
// so far. The graph has one cycle.
|
||||
TEST(CalculatorGraph, Cycle) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
input_side_packet: 'global_counter'
|
||||
@@ -2666,7 +2666,7 @@ TEST(CalculatorGraph, Cycle) {
|
||||
input_stream: 'sum'
|
||||
output_stream: 'old_sum'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("sum", &config, &packet_dump);
|
||||
|
||||
@@ -2693,7 +2693,7 @@ TEST(CalculatorGraph, Cycle) {
|
||||
// packet timestamps ignored.
|
||||
TEST(CalculatorGraph, CycleUntimed) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream_handler {
|
||||
input_stream_handler: 'BarrierInputStreamHandler'
|
||||
}
|
||||
@@ -2717,7 +2717,7 @@ TEST(CalculatorGraph, CycleUntimed) {
|
||||
input_stream: 'sum'
|
||||
output_stream: 'old_sum'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("sum", &config, &packet_dump);
|
||||
|
||||
@@ -2743,7 +2743,7 @@ TEST(CalculatorGraph, CycleUntimed) {
|
||||
// The graph has two cycles.
|
||||
TEST(CalculatorGraph, DirectFormI) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
input_side_packet: 'global_counter'
|
||||
@@ -2818,7 +2818,7 @@ TEST(CalculatorGraph, DirectFormI) {
|
||||
input_stream_handler: 'EarlyCloseInputStreamHandler'
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("y", &config, &packet_dump);
|
||||
|
||||
@@ -2850,7 +2850,7 @@ TEST(CalculatorGraph, DirectFormI) {
|
||||
// The graph has two cycles.
|
||||
TEST(CalculatorGraph, DirectFormII) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'GlobalCountSourceCalculator'
|
||||
input_side_packet: 'global_counter'
|
||||
@@ -2920,7 +2920,7 @@ TEST(CalculatorGraph, DirectFormII) {
|
||||
input_stream_handler: 'EarlyCloseInputStreamHandler'
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("y", &config, &packet_dump);
|
||||
|
||||
@@ -2951,7 +2951,7 @@ TEST(CalculatorGraph, DotProduct) {
|
||||
// The use of BarrierInputStreamHandler in this graph aligns the input
|
||||
// packets to a calculator by arrival order rather than by timestamp.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream_handler {
|
||||
input_stream_handler: 'BarrierInputStreamHandler'
|
||||
}
|
||||
@@ -3008,7 +3008,7 @@ TEST(CalculatorGraph, DotProduct) {
|
||||
input_stream: 'z_product'
|
||||
output_stream: 'dot_product'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("dot_product", &config, &packet_dump);
|
||||
|
||||
@@ -3047,7 +3047,7 @@ TEST(CalculatorGraph, DotProduct) {
|
||||
|
||||
TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
input_stream: 'in_a'
|
||||
@@ -3057,7 +3057,7 @@ TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
|
||||
}
|
||||
input_stream: 'in_a'
|
||||
input_stream: 'in_b'
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -3076,14 +3076,14 @@ TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
|
||||
|
||||
TEST(CalculatorGraph, TerminatesOnCancelAfterPause) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
input_stream: 'in'
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -3138,7 +3138,7 @@ REGISTER_PACKET_GENERATOR(PassThroughGenerator);
|
||||
TEST(CalculatorGraph, RecoverAfterRunError) {
|
||||
PacketGeneratorGraph generator_graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: 'calculator1'
|
||||
calculator: 'CountingSourceCalculator'
|
||||
@@ -3157,7 +3157,7 @@ TEST(CalculatorGraph, RecoverAfterRunError) {
|
||||
status_handler: 'FailableStatusHandler'
|
||||
input_side_packet: 'status_handler_command'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
int packet_count = 0;
|
||||
CalculatorGraph graph;
|
||||
@@ -3259,7 +3259,7 @@ TEST(CalculatorGraph, RecoverAfterRunError) {
|
||||
TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) {
|
||||
using Semaphore = SemaphoreCalculator::Semaphore;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'SemaphoreCalculator'
|
||||
input_stream: 'in'
|
||||
@@ -3277,7 +3277,7 @@ TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) {
|
||||
input_stream: 'in'
|
||||
input_stream: 'in_2'
|
||||
max_queue_size: 100
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
graph.SetGraphInputStreamAddMode(
|
||||
@@ -3352,7 +3352,7 @@ TEST(CalculatorGraph, AddPacketNoBusyLoop) {
|
||||
// out
|
||||
//
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
max_queue_size: 1
|
||||
node {
|
||||
@@ -3366,7 +3366,7 @@ TEST(CalculatorGraph, AddPacketNoBusyLoop) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
graph.SetGraphInputStreamAddMode(
|
||||
@@ -3487,7 +3487,7 @@ absl::Status DoProcess(const InputStreamShardSet& inputs,
|
||||
TEST(CalculatorGraph, ObserveOutputStream) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'count'
|
||||
@@ -3503,7 +3503,7 @@ TEST(CalculatorGraph, ObserveOutputStream) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3539,7 +3539,7 @@ class PassThroughSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& options) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'INPUT:input'
|
||||
output_stream: 'OUTPUT:output'
|
||||
node {
|
||||
@@ -3547,7 +3547,7 @@ class PassThroughSubgraph : public Subgraph {
|
||||
input_stream: 'input'
|
||||
output_stream: 'output'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -3556,7 +3556,7 @@ REGISTER_MEDIAPIPE_GRAPH(PassThroughSubgraph);
|
||||
TEST(CalculatorGraph, ObserveOutputStreamSubgraph) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'count'
|
||||
@@ -3567,7 +3567,7 @@ TEST(CalculatorGraph, ObserveOutputStreamSubgraph) {
|
||||
input_stream: 'INPUT:count'
|
||||
output_stream: 'OUTPUT:out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3590,7 +3590,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
|
||||
const int max_count = 10;
|
||||
const int fail_count = 6;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'count'
|
||||
@@ -3606,7 +3606,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3640,7 +3640,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
|
||||
TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'count'
|
||||
@@ -3656,7 +3656,7 @@ TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3677,7 +3677,7 @@ TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
|
||||
TEST(CalculatorGraph, FastSourceSlowSink) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
num_threads: 2
|
||||
max_queue_size: 100
|
||||
node {
|
||||
@@ -3686,7 +3686,7 @@ TEST(CalculatorGraph, FastSourceSlowSink) {
|
||||
input_side_packet: 'MAX_COUNT:max_count'
|
||||
}
|
||||
node { calculator: 'SlowCountingSinkCalculator' input_stream: 'out' }
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3707,9 +3707,9 @@ TEST(CalculatorGraph, GraphFinishesWhilePaused) {
|
||||
//
|
||||
// graph.WaitUntilDone must not block forever.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node { calculator: 'OneShot20MsCalculator' }
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_EXPECT_OK(graph.StartRun({}));
|
||||
@@ -3729,7 +3729,7 @@ TEST(CalculatorGraph, ConstructAndDestruct) { CalculatorGraph graph; }
|
||||
TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
|
||||
const int max_count = 10;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CountingSourceCalculator'
|
||||
output_stream: 'a'
|
||||
@@ -3752,7 +3752,7 @@ TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
|
||||
input_side_packet: 'ERROR_ON_OPEN:fail'
|
||||
}
|
||||
node { calculator: 'IntSinkCalculator' input_stream: 'd' }
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
|
||||
@@ -3764,7 +3764,7 @@ TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
|
||||
|
||||
TEST(CalculatorGraph, ReuseValidatedGraphConfig) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
packet_generator {
|
||||
packet_generator: "StaticCounterStringGenerator"
|
||||
input_side_packet: "created_by_factory"
|
||||
@@ -3798,7 +3798,7 @@ TEST(CalculatorGraph, ReuseValidatedGraphConfig) {
|
||||
input_side_packet: "global_counter"
|
||||
output_stream: "unused"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
ValidatedGraphConfig validated_graph;
|
||||
MP_ASSERT_OK(validated_graph.Initialize(config));
|
||||
|
||||
@@ -3841,7 +3841,7 @@ class TestRangeStdDevSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& options) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: 'node_converted'
|
||||
output_stream: 'DATA:range'
|
||||
output_stream: 'SUM:range_sum'
|
||||
@@ -3860,7 +3860,7 @@ class TestRangeStdDevSubgraph : public Subgraph {
|
||||
input_stream: 'MEAN:range_mean'
|
||||
output_stream: 'range_stddev'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -3871,7 +3871,7 @@ class TestMergeSaverSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& options) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'DATA1:range1'
|
||||
input_stream: 'DATA2:range2'
|
||||
output_stream: 'MERGE:merge'
|
||||
@@ -3888,7 +3888,7 @@ class TestMergeSaverSubgraph : public Subgraph {
|
||||
input_stream: 'merge'
|
||||
output_stream: 'final'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -3896,7 +3896,7 @@ REGISTER_MEDIAPIPE_GRAPH(TestMergeSaverSubgraph);
|
||||
|
||||
CalculatorGraphConfig GetConfigWithSubgraphs() {
|
||||
CalculatorGraphConfig proto =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
# Ensure stream name for FindOutputStreamManager
|
||||
output_stream: 'MERGE:merge'
|
||||
packet_generator {
|
||||
@@ -3952,7 +3952,7 @@ CalculatorGraphConfig GetConfigWithSubgraphs() {
|
||||
input_stream: 'DATA2:range5_stddev'
|
||||
output_stream: 'FINAL:final_stddev'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return proto;
|
||||
}
|
||||
|
||||
@@ -3989,7 +3989,7 @@ TEST(CalculatorGraph, ReservedNameExecutorConfig) {
|
||||
// A reserved executor name such as "__gpu" must not be used.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
executor {
|
||||
name: '__gpu'
|
||||
@@ -4003,7 +4003,7 @@ TEST(CalculatorGraph, ReservedNameExecutorConfig) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(), testing::AllOf(testing::HasSubstr("__gpu"),
|
||||
@@ -4014,7 +4014,7 @@ TEST(CalculatorGraph, ReservedNameNodeExecutor) {
|
||||
// A reserved executor name such as "__gpu" must not be used.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
@@ -4022,7 +4022,7 @@ TEST(CalculatorGraph, ReservedNameNodeExecutor) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(), testing::AllOf(testing::HasSubstr("__gpu"),
|
||||
@@ -4035,7 +4035,7 @@ TEST(CalculatorGraph, NonExistentExecutor) {
|
||||
// provided to the graph with a CalculatorGraph::SetExecutor() call.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
@@ -4043,7 +4043,7 @@ TEST(CalculatorGraph, NonExistentExecutor) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4059,7 +4059,7 @@ TEST(CalculatorGraph, UndeclaredExecutor) {
|
||||
MP_ASSERT_OK(
|
||||
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
@@ -4067,7 +4067,7 @@ TEST(CalculatorGraph, UndeclaredExecutor) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4080,7 +4080,7 @@ TEST(CalculatorGraph, UntypedExecutorDeclaredButNotSet) {
|
||||
// the graph with a CalculatorGraph::SetExecutor() call.
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
executor { name: 'xyz' }
|
||||
node {
|
||||
@@ -4089,7 +4089,7 @@ TEST(CalculatorGraph, UntypedExecutorDeclaredButNotSet) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4103,7 +4103,7 @@ TEST(CalculatorGraph, DuplicateExecutorConfig) {
|
||||
MP_ASSERT_OK(
|
||||
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
executor { name: 'xyz' }
|
||||
executor { name: 'xyz' }
|
||||
@@ -4113,7 +4113,7 @@ TEST(CalculatorGraph, DuplicateExecutorConfig) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4128,7 +4128,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
|
||||
MP_ASSERT_OK(
|
||||
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
executor {
|
||||
name: 'xyz'
|
||||
@@ -4143,7 +4143,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
|
||||
input_stream: 'in'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4156,7 +4156,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
|
||||
TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
num_threads: 1
|
||||
executor {
|
||||
@@ -4175,7 +4175,7 @@ TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status status = graph.Initialize(config);
|
||||
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(status.message(),
|
||||
@@ -4188,7 +4188,7 @@ TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
|
||||
TEST(CalculatorGraph, NumThreadsAndNonDefaultExecutorConfig) {
|
||||
CalculatorGraph graph;
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: 'in'
|
||||
num_threads: 1
|
||||
executor {
|
||||
@@ -4209,7 +4209,7 @@ TEST(CalculatorGraph, NumThreadsAndNonDefaultExecutorConfig) {
|
||||
input_stream: 'mid'
|
||||
output_stream: 'out'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_EXPECT_OK(graph.Initialize(config));
|
||||
}
|
||||
|
||||
@@ -4227,14 +4227,14 @@ TEST(CalculatorGraph, RunWithNumThreadsInExecutorConfig) {
|
||||
{"ThreadPoolExecutor", 1, false}};
|
||||
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] { num_threads: 0 }
|
||||
}
|
||||
}
|
||||
node { calculator: 'PthreadSelfSourceCalculator' output_stream: 'out' }
|
||||
)");
|
||||
)pb");
|
||||
ThreadPoolExecutorOptions* default_executor_options =
|
||||
config.mutable_executor(0)->mutable_options()->MutableExtension(
|
||||
ThreadPoolExecutorOptions::ext);
|
||||
@@ -4266,7 +4266,7 @@ TEST(CalculatorGraph, CalculatorGraphNotInitialized) {
|
||||
|
||||
TEST(CalculatorGraph, SimulateAssertFailure) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
num_threads: 2
|
||||
node {
|
||||
calculator: 'PassThroughCalculator'
|
||||
@@ -4277,7 +4277,7 @@ TEST(CalculatorGraph, SimulateAssertFailure) {
|
||||
}
|
||||
input_stream: 'in_a'
|
||||
input_stream: 'in_b'
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -4293,7 +4293,7 @@ TEST(CalculatorGraph, SimulateAssertFailure) {
|
||||
// the source node stops the graph.
|
||||
TEST(CalculatorGraph, CheckInputTimestamp) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CheckInputTimestampSourceCalculator'
|
||||
output_stream: 'integer'
|
||||
@@ -4302,7 +4302,7 @@ TEST(CalculatorGraph, CheckInputTimestamp) {
|
||||
calculator: 'CheckInputTimestampSinkCalculator'
|
||||
input_stream: 'integer'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Run());
|
||||
@@ -4314,7 +4314,7 @@ TEST(CalculatorGraph, CheckInputTimestamp) {
|
||||
// source node.
|
||||
TEST(CalculatorGraph, CheckInputTimestamp2) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: 'CheckInputTimestamp2SourceCalculator'
|
||||
output_stream: 'integer'
|
||||
@@ -4323,7 +4323,7 @@ TEST(CalculatorGraph, CheckInputTimestamp2) {
|
||||
calculator: 'CheckInputTimestamp2SinkCalculator'
|
||||
input_stream: 'integer'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Run());
|
||||
@@ -4331,7 +4331,7 @@ TEST(CalculatorGraph, CheckInputTimestamp2) {
|
||||
|
||||
TEST(CalculatorGraph, GraphInputStreamWithTag) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "VIDEO_METADATA:video_metadata"
|
||||
input_stream: "max_count"
|
||||
node {
|
||||
@@ -4341,7 +4341,7 @@ TEST(CalculatorGraph, GraphInputStreamWithTag) {
|
||||
output_stream: "FIRST_INPUT:output_0"
|
||||
output_stream: "output_1"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::vector<Packet> packet_dump;
|
||||
tool::AddVectorSink("output_0", &config, &packet_dump);
|
||||
CalculatorGraph graph;
|
||||
|
||||
@@ -91,7 +91,7 @@ class ParallelExecutionTest : public testing::Test {
|
||||
|
||||
TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
|
||||
CalculatorGraphConfig graph_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input"
|
||||
node {
|
||||
calculator: "SlowPlusOneCalculator"
|
||||
@@ -111,7 +111,7 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
|
||||
input_side_packet: "CALLBACK:callback"
|
||||
}
|
||||
num_threads: 5
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// Starts MediaPipe graph.
|
||||
CalculatorGraph graph(graph_config);
|
||||
|
||||
@@ -48,14 +48,14 @@ class GraphServiceTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "in"
|
||||
node {
|
||||
calculator: "TestServiceCalculator"
|
||||
input_stream: "in"
|
||||
output_stream: "out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_ASSERT_OK(graph_.Initialize(config));
|
||||
MP_ASSERT_OK(
|
||||
graph_.ObserveOutputStream("out", [this](const Packet& packet) {
|
||||
@@ -98,11 +98,11 @@ TEST_F(GraphServiceTest, UseInCalculator) {
|
||||
|
||||
TEST_F(GraphServiceTest, Contract) {
|
||||
const CalculatorGraphConfig::Node node =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
|
||||
calculator: "TestServiceCalculator"
|
||||
input_stream: "in"
|
||||
output_stream: "out"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorContract contract;
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(TestServiceCalculator::GetContract(&contract));
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace {
|
||||
|
||||
// Shows validation success for a graph and a subgraph.
|
||||
TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
@@ -42,8 +42,8 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
input_stream: "stream_1" # Any Type.
|
||||
output_stream: "stream_2" # Same as input.
|
||||
}
|
||||
)");
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
)pb");
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
node {
|
||||
@@ -56,7 +56,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
input_stream: "INPUT:stream_2" # Any Type.
|
||||
output_stream: "OUTPUT:stream_3" # Same as input.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MP_EXPECT_OK(
|
||||
@@ -66,7 +66,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
graph_1.Initialize({config_1, config_2}, {}, {}, "PassThroughGraph"));
|
||||
EXPECT_THAT(
|
||||
graph_1.Config(),
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
@@ -76,7 +76,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
output_stream: "stream_2"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
GraphValidation validation_2;
|
||||
MP_EXPECT_OK(validation_2.Validate({config_1, config_2}, {}));
|
||||
@@ -84,7 +84,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
MP_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {}));
|
||||
EXPECT_THAT(
|
||||
graph_2.Config(),
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
node {
|
||||
@@ -99,7 +99,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
|
||||
output_stream: "stream_3"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
// Shows validation failure due to an unregistered subgraph.
|
||||
@@ -129,7 +129,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
}
|
||||
)",
|
||||
&config_1));
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
node {
|
||||
@@ -152,8 +152,8 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
input_stream: "INPUT:stream_2" # Any Type.
|
||||
output_stream: "OUTPUT:stream_3" # Same as input.
|
||||
}
|
||||
)");
|
||||
auto options = ParseTextProtoOrDie<Subgraph::SubgraphOptions>(R"(
|
||||
)pb");
|
||||
auto options = ParseTextProtoOrDie<Subgraph::SubgraphOptions>(R"pb(
|
||||
options: {
|
||||
[mediapipe.TemplateSubgraphOptions.ext]: {
|
||||
dict: {
|
||||
@@ -163,7 +163,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MP_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {},
|
||||
@@ -173,7 +173,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
"PassThroughGraph", &options));
|
||||
EXPECT_THAT(
|
||||
graph_1.Config(),
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_stream: "INPUT:stream_9"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
@@ -184,7 +184,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
output_stream: "stream_2"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
GraphValidation validation_2;
|
||||
MP_EXPECT_OK(validation_2.Validate({config_2}, {config_1}));
|
||||
@@ -192,7 +192,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
MP_EXPECT_OK(graph_2.Initialize({config_2}, {config_1}));
|
||||
EXPECT_THAT(
|
||||
graph_2.Config(),
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:stream_1"
|
||||
output_stream: "OUTPUT:stream_2"
|
||||
node {
|
||||
@@ -207,14 +207,14 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
|
||||
output_stream: "stream_3"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
// Shows passing validation of optional subgraph inputs and output streams.
|
||||
TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
// A subgraph defining two optional input streams
|
||||
// and two optional output streams.
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_stream: "INPUT:input_0"
|
||||
input_stream: "INPUT:1:input_1"
|
||||
@@ -226,11 +226,11 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
input_stream: "input_1" # Any Type.
|
||||
output_stream: "output_0" # Same as input.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// An enclosing graph that specifies one of the two optional input streams
|
||||
// and one of the two optional output streams.
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:foo_in"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
node {
|
||||
@@ -243,7 +243,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
input_stream: "INPUT:foo_bar" # Any Type.
|
||||
output_stream: "OUTPUT:foo_out" # Same as input.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MP_EXPECT_OK(validation_1.Validate({config_1, config_2}, {}));
|
||||
@@ -253,7 +253,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
graph_1.Config(),
|
||||
|
||||
// The result includes only the requested input and output streams.
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:foo_in"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
node {
|
||||
@@ -268,7 +268,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
output_stream: "foo_out"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
MP_EXPECT_OK(graph_1.StartRun({}));
|
||||
MP_EXPECT_OK(graph_1.CloseAllPacketSources());
|
||||
@@ -279,7 +279,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
|
||||
TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
|
||||
// A subgraph defining two optional input streams
|
||||
// and two optional output streams.
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_stream: "INPUT:input_0"
|
||||
input_stream: "INPUT:1:input_1"
|
||||
@@ -291,11 +291,11 @@ TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
|
||||
input_stream: "input_1" # Any Type.
|
||||
output_stream: "output_0" # Same as input.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// An enclosing graph that specifies one of the two optional input streams
|
||||
// and both of the two optional output streams.
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:foo_in"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
node {
|
||||
@@ -309,7 +309,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
|
||||
input_stream: "INPUT:1:foo_bar" # Any Type.
|
||||
output_stream: "OUTPUT:foo_out" # Same as input.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
absl::Status status = validation_1.Validate({config_1, config_2}, {});
|
||||
@@ -344,7 +344,7 @@ REGISTER_CALCULATOR(OptionalSideInputTestCalculator);
|
||||
|
||||
TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
|
||||
// A subgraph defining one optional input-side-packet.
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_side_packet: "INPUT:input_0"
|
||||
output_stream: "OUTPUT:output_0"
|
||||
@@ -353,17 +353,17 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
|
||||
input_side_packet: "SIDEINPUT:input_0" # std::string
|
||||
output_stream: "OUTPUT:output_0" # std::string
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// An enclosing graph that omits the optional input-side-packet.
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "INPUT:foo_in"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
node {
|
||||
calculator: "PassThroughGraph"
|
||||
output_stream: "OUTPUT:foo_out" # std::string
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MP_EXPECT_OK(validation_1.Validate({config_1, config_2}, {}));
|
||||
@@ -373,7 +373,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
|
||||
graph_1.Config(),
|
||||
|
||||
// The expanded graph omits the optional input-side-packet.
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "INPUT:foo_in"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
node {
|
||||
@@ -382,7 +382,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
std::map<std::string, Packet> side_packets;
|
||||
side_packets.insert({"foo_in", mediapipe::Adopt(new std::string("input"))});
|
||||
@@ -393,7 +393,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
|
||||
|
||||
TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
// A subgraph defining one optional side-packet and two optional inputs.
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_side_packet: "INPUT:input_0"
|
||||
input_stream: "SELECT:select"
|
||||
@@ -406,10 +406,10 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
input_stream: "ENABLE:enable"
|
||||
output_stream: "OUTPUT:output_0" # std::string
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
// An enclosing graph that specifies just one optional input.
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "INPUT:foo_in"
|
||||
input_stream: "SELECT:foo_select"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
@@ -418,7 +418,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
input_stream: "SELECT:foo_select"
|
||||
output_stream: "OUTPUT:foo_out" # std::string
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MP_ASSERT_OK(validation_1.Validate({config_1, config_2}, {}));
|
||||
@@ -430,7 +430,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
// The expanded graph includes only the specified input, "SELECT".
|
||||
// Without the fix to RemoveIgnoredStreams(), the expanded graph
|
||||
// includes the wrong input.
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "INPUT:foo_in"
|
||||
input_stream: "SELECT:foo_select"
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
@@ -441,7 +441,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
output_stream: "OUTPUT:foo_out"
|
||||
}
|
||||
executor {}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
std::map<std::string, Packet> side_packets;
|
||||
side_packets.insert({"foo_in", mediapipe::Adopt(new std::string("input"))});
|
||||
@@ -453,7 +453,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
|
||||
// Shows a calculator graph running with and without one optional side packet.
|
||||
TEST(GraphValidationTest, OptionalInputsForGraph) {
|
||||
// A subgraph defining one optional input-side-packet.
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "PassThroughGraph"
|
||||
input_side_packet: "side_input_0"
|
||||
input_stream: "stream_input_0"
|
||||
@@ -466,7 +466,7 @@ TEST(GraphValidationTest, OptionalInputsForGraph) {
|
||||
input_stream: "ENABLE:stream_input_1"
|
||||
output_stream: "OUTPUT:output_0"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
GraphValidation validation_1;
|
||||
MP_EXPECT_OK(validation_1.Validate({config_1}, {}));
|
||||
CalculatorGraph graph_1;
|
||||
|
||||
@@ -249,7 +249,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfig) {
|
||||
// Checks histogram_interval_size_usec and num_histogram_intervals.
|
||||
CalculatorProfile actual =
|
||||
GetCalculatorProfilesMap()->find(kDummyTestCalculatorName)->second;
|
||||
EXPECT_THAT(actual, EqualsProto(R"(
|
||||
EXPECT_THAT(actual, EqualsProto(R"pb(
|
||||
name: "DummyTestCalculator"
|
||||
process_runtime {
|
||||
total: 0
|
||||
@@ -287,7 +287,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfig) {
|
||||
count: 0
|
||||
}
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
}
|
||||
|
||||
// Tests that Initialize() uses the ProfilerConfig in the graph definition.
|
||||
@@ -313,7 +313,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfigWithoutStreamLatency) {
|
||||
// Checks histogram_interval_size_usec and num_histogram_intervals.
|
||||
CalculatorProfile actual =
|
||||
GetCalculatorProfilesMap()->find(kDummyTestCalculatorName)->second;
|
||||
EXPECT_THAT(actual, EqualsProto(R"(
|
||||
EXPECT_THAT(actual, EqualsProto(R"pb(
|
||||
name: "DummyTestCalculator"
|
||||
process_runtime {
|
||||
total: 0
|
||||
@@ -323,7 +323,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfigWithoutStreamLatency) {
|
||||
count: 0
|
||||
count: 0
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
}
|
||||
|
||||
// Tests that Initialize() reads all the configs defined in the graph
|
||||
@@ -654,11 +654,11 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntime) {
|
||||
simulation_clock->ThreadFinish();
|
||||
|
||||
ASSERT_EQ(profiles.size(), 1);
|
||||
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"(
|
||||
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"pb(
|
||||
name: "DummyTestCalculator"
|
||||
open_runtime: 100
|
||||
process_runtime { total: 0 }
|
||||
)")));
|
||||
)pb")));
|
||||
// Checks packets_info_ map hasn't changed.
|
||||
ASSERT_EQ(GetPacketsInfoMap()->size(), 0);
|
||||
}
|
||||
@@ -711,7 +711,7 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntimeWithStreamLatency) {
|
||||
CalculatorProfile source_profile =
|
||||
GetProfileWithName(profiles, "source_calc");
|
||||
|
||||
EXPECT_THAT(source_profile, EqualsProto(R"(
|
||||
EXPECT_THAT(source_profile, EqualsProto(R"pb(
|
||||
name: "source_calc"
|
||||
open_runtime: 150
|
||||
process_runtime {
|
||||
@@ -732,7 +732,7 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntimeWithStreamLatency) {
|
||||
num_intervals: 1
|
||||
count: 0
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
|
||||
// Check packets_info_ map has been updated.
|
||||
ASSERT_EQ(GetPacketsInfoMap()->size(), 1);
|
||||
@@ -773,7 +773,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntime) {
|
||||
std::vector<CalculatorProfile> profiles = Profiles();
|
||||
simulation_clock->ThreadFinish();
|
||||
|
||||
EXPECT_THAT(profiles[0], EqualsProto(R"(
|
||||
EXPECT_THAT(profiles[0], EqualsProto(R"pb(
|
||||
name: "DummyTestCalculator"
|
||||
close_runtime: 100
|
||||
process_runtime {
|
||||
@@ -782,7 +782,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntime) {
|
||||
num_intervals: 1
|
||||
count: 0
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
}
|
||||
|
||||
// Tests that SetCloseRuntime() updates |close_runtime| and doesn't affect other
|
||||
@@ -832,7 +832,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntimeWithStreamLatency) {
|
||||
CalculatorProfile source_profile =
|
||||
GetProfileWithName(profiles, "source_calc");
|
||||
|
||||
EXPECT_THAT(source_profile, EqualsProto(R"(
|
||||
EXPECT_THAT(source_profile, EqualsProto(R"pb(
|
||||
name: "source_calc"
|
||||
close_runtime: 100
|
||||
process_runtime {
|
||||
@@ -863,7 +863,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntimeWithStreamLatency) {
|
||||
count: 0
|
||||
}
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
PacketInfo expected_packet_info = {0,
|
||||
/*production_time_usec=*/1000 + 100,
|
||||
/*source_process_start_usec=*/1000 + 0};
|
||||
@@ -1003,7 +1003,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSample) {
|
||||
simulation_clock->ThreadFinish();
|
||||
|
||||
ASSERT_EQ(profiles.size(), 1);
|
||||
EXPECT_THAT(profiles[0], EqualsProto(R"(
|
||||
EXPECT_THAT(profiles[0], EqualsProto(R"pb(
|
||||
name: "DummyTestCalculator"
|
||||
process_runtime {
|
||||
total: 150
|
||||
@@ -1011,7 +1011,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSample) {
|
||||
num_intervals: 1
|
||||
count: 1
|
||||
}
|
||||
)"));
|
||||
)pb"));
|
||||
// Checks packets_info_ map hasn't changed.
|
||||
ASSERT_EQ(GetPacketsInfoMap()->size(), 0);
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
|
||||
CalculatorProfile source_profile =
|
||||
GetProfileWithName(profiles, "source_calc");
|
||||
|
||||
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"(
|
||||
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"pb(
|
||||
process_runtime {
|
||||
total: 150
|
||||
interval_size_usec: 1000000
|
||||
@@ -1080,7 +1080,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
|
||||
num_intervals: 1
|
||||
count: 1
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
// Check packets_info_ map has been updated.
|
||||
ASSERT_EQ(GetPacketsInfoMap()->size(), 1);
|
||||
@@ -1114,7 +1114,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
|
||||
// 1000 process output latency total = 2000 (end) + 250 - 1000 (when source
|
||||
// started) = 1250 For "stream_0" should have not changed since it was empty.
|
||||
// For "stream_1" = 2000 (end) - 1250 (when source finished) = 850
|
||||
EXPECT_THAT(consumer_profile, Partially(EqualsProto(R"(
|
||||
EXPECT_THAT(consumer_profile, Partially(EqualsProto(R"pb(
|
||||
name: "consumer_calc"
|
||||
process_input_latency { total: 1000 }
|
||||
process_output_latency { total: 1250 }
|
||||
@@ -1126,7 +1126,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
|
||||
name: "stream_1"
|
||||
latency { total: 850 }
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
// Check packets_info_ map for PacketId({"stream_1", 100}) should not yet be
|
||||
// garbage collected.
|
||||
|
||||
@@ -122,11 +122,11 @@ TEST_F(GraphTracerTest, EmptyTrace) {
|
||||
|
||||
// Validate the GraphTrace data.
|
||||
EXPECT_THAT(GetTrace(),
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
|
||||
base_time: 0
|
||||
base_timestamp: 0
|
||||
stream_name: ""
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
TEST_F(GraphTracerTest, CalculatorTrace) {
|
||||
@@ -145,7 +145,7 @@ TEST_F(GraphTracerTest, CalculatorTrace) {
|
||||
|
||||
// Validate the GraphTrace data.
|
||||
EXPECT_THAT(
|
||||
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
|
||||
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
|
||||
base_time: 1608911100000000
|
||||
base_timestamp: 1608911100000000
|
||||
stream_name: ""
|
||||
@@ -166,7 +166,7 @@ TEST_F(GraphTracerTest, CalculatorTrace) {
|
||||
}
|
||||
output_trace { packet_timestamp: 0 stream_id: 2 event_data: 2 }
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
TEST_F(GraphTracerTest, GraphTrace) {
|
||||
@@ -226,7 +226,7 @@ TEST_F(GraphTracerTest, GraphTrace) {
|
||||
|
||||
// Validate the GraphTrace data.
|
||||
EXPECT_THAT(
|
||||
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
|
||||
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
|
||||
base_time: 1608911100000000
|
||||
base_timestamp: 1608911100000000
|
||||
stream_name: ""
|
||||
@@ -300,7 +300,7 @@ TEST_F(GraphTracerTest, GraphTrace) {
|
||||
}
|
||||
output_trace { packet_timestamp: 5 stream_id: 5 event_data: 10 }
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
// No timestamps are completed before start_time_.
|
||||
// One timestamp is completed before start_time_ + 10ms.
|
||||
@@ -629,11 +629,11 @@ TEST_F(GraphTracerE2ETest, PassThroughGraphProfile) {
|
||||
MP_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles));
|
||||
EXPECT_EQ(1, profiles.size());
|
||||
CalculatorProfile expected =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorProfile>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorProfile>(R"pb(
|
||||
name: "LambdaCalculator"
|
||||
open_runtime: 0
|
||||
close_runtime: 0
|
||||
input_stream_profiles { name: "input_0" back_edge: false })");
|
||||
input_stream_profiles { name: "input_0" back_edge: false })pb");
|
||||
|
||||
FillHistogram({20001, 20001, 20001, 20001, 20001, 20001},
|
||||
expected.mutable_process_runtime());
|
||||
@@ -659,7 +659,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
|
||||
absl::InfiniteFuture(), &trace);
|
||||
GraphTrace node_timestamps = NodeTimestamps(trace);
|
||||
EXPECT_THAT(node_timestamps,
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
|
||||
calculator_trace { node_id: 1 input_timestamp: 10000 }
|
||||
calculator_trace { node_id: 2 input_timestamp: 10000 }
|
||||
calculator_trace { node_id: 3 input_timestamp: 10000 }
|
||||
@@ -805,7 +805,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
|
||||
calculator_trace { node_id: 1 input_timestamp: 50001 }
|
||||
calculator_trace { node_id: 1 input_timestamp: 10000 }
|
||||
calculator_trace { node_id: 1 input_timestamp: 10000 }
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
// Validate a one-timestamp slice of the event trace.
|
||||
GraphTrace trace_2;
|
||||
@@ -817,7 +817,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
|
||||
EXPECT_THAT(
|
||||
trace_2,
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
|
||||
R"(
|
||||
R"pb(
|
||||
base_time: 1544086800000000
|
||||
base_timestamp: 10000
|
||||
stream_name: ""
|
||||
@@ -986,7 +986,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
|
||||
event_type: NOT_READY
|
||||
start_time: 25005
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
// Read a GraphProfile from a file path.
|
||||
@@ -1047,7 +1047,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFiles) {
|
||||
StripDataIds(&trace);
|
||||
}
|
||||
EXPECT_THAT(profile_2,
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphProfile>(R"(
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphProfile>(R"pb(
|
||||
graph_trace {
|
||||
base_time: 1544086800000000
|
||||
base_timestamp: 0
|
||||
@@ -1233,7 +1233,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFiles) {
|
||||
trace_enabled: true
|
||||
}
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
TEST_F(GraphTracerE2ETest, DisableLoggingToDisk) {
|
||||
@@ -1295,7 +1295,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
|
||||
EXPECT_THAT(
|
||||
trace_1,
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
|
||||
R"(
|
||||
R"pb(
|
||||
base_time: 1100
|
||||
base_timestamp: 1000
|
||||
stream_name: ""
|
||||
@@ -1324,7 +1324,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
|
||||
finish_time: 2100
|
||||
thread_id: 0
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
|
||||
GraphTrace trace_2;
|
||||
builder.CreateLog(buffer, absl::InfinitePast(), absl::InfiniteFuture(),
|
||||
@@ -1332,7 +1332,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
|
||||
EXPECT_THAT(
|
||||
trace_2,
|
||||
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
|
||||
R"(
|
||||
R"pb(
|
||||
base_time: 1100
|
||||
base_timestamp: 1000
|
||||
stream_name: ""
|
||||
@@ -1368,7 +1368,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
|
||||
output_trace { packet_timestamp: 0 stream_id: 2 event_data: 0 }
|
||||
thread_id: 0
|
||||
}
|
||||
)")));
|
||||
)pb")));
|
||||
}
|
||||
|
||||
// Show that trace_enabled activates the GlContextProfiler.
|
||||
|
||||
@@ -30,7 +30,7 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) {
|
||||
// A single calculator with two input streams, and two output streams. This
|
||||
// calculator passes all the input packets along.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input0"
|
||||
input_stream: "input1"
|
||||
node {
|
||||
@@ -47,7 +47,7 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink_0, sink_1;
|
||||
tool::AddVectorSink("output0", &config, &sink_0);
|
||||
tool::AddVectorSink("output1", &config, &sink_1);
|
||||
@@ -88,7 +88,7 @@ TEST(DefaultInputStreamHandlerTest, Batches) {
|
||||
// A single batching calculator with one input stream and one output stream.
|
||||
// This calculator passes all the input packets onto the output streams.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input0"
|
||||
node {
|
||||
calculator: "PassThroughCalculator"
|
||||
@@ -102,7 +102,7 @@ TEST(DefaultInputStreamHandlerTest, Batches) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink;
|
||||
tool::AddVectorSink("output0", &config, &sink);
|
||||
|
||||
@@ -152,7 +152,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
|
||||
// A single batching calculator with one input stream and one output stream.
|
||||
// This calculator passes all the input packets onto the output streams.
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input0"
|
||||
node {
|
||||
calculator: "PassThroughCalculator"
|
||||
@@ -166,7 +166,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink;
|
||||
tool::AddVectorSink("output0", &config, &sink);
|
||||
|
||||
@@ -211,7 +211,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
|
||||
// batching except for the first timestamp of the batch.
|
||||
TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input0"
|
||||
input_stream: "input1"
|
||||
node {
|
||||
@@ -233,7 +233,7 @@ TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) {
|
||||
input_stream: "input1_batched"
|
||||
output_stream: "output"
|
||||
output_stream: "dummy"
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink;
|
||||
tool::AddVectorSink("output", &config, &sink);
|
||||
CalculatorGraph graph;
|
||||
|
||||
@@ -149,18 +149,18 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPackets) {
|
||||
// regulated by FixedSizeInputStreamHandler.
|
||||
CalculatorGraphConfig graph_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(node {
|
||||
calculator: "TestSourceCalculator"
|
||||
output_stream: "input_packets"
|
||||
}
|
||||
node {
|
||||
calculator: "TestSlowCalculator"
|
||||
input_stream: "input_packets"
|
||||
output_stream: "output_packets"
|
||||
input_stream_handler {
|
||||
input_stream_handler: "FixedSizeInputStreamHandler"
|
||||
R"pb(node {
|
||||
calculator: "TestSourceCalculator"
|
||||
output_stream: "input_packets"
|
||||
}
|
||||
})");
|
||||
node {
|
||||
calculator: "TestSlowCalculator"
|
||||
input_stream: "input_packets"
|
||||
output_stream: "output_packets"
|
||||
input_stream_handler {
|
||||
input_stream_handler: "FixedSizeInputStreamHandler"
|
||||
}
|
||||
})pb");
|
||||
SetFixedMinSize(graph_config.mutable_node(1), GetParam());
|
||||
std::vector<Packet> output_packets;
|
||||
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
|
||||
@@ -190,21 +190,21 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
|
||||
// CountingSourceCalculator will stay throttled and the test will time out.
|
||||
CalculatorGraphConfig graph_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(max_queue_size: 10
|
||||
node {
|
||||
calculator: "CountingSourceCalculator"
|
||||
input_side_packet: "MAX_COUNT:max_count"
|
||||
input_side_packet: "BATCH_SIZE:batch_size"
|
||||
output_stream: "input_packets"
|
||||
}
|
||||
node {
|
||||
calculator: "PassThroughCalculator"
|
||||
input_stream: "input_packets"
|
||||
output_stream: "output_packets"
|
||||
input_stream_handler {
|
||||
input_stream_handler: "FixedSizeInputStreamHandler"
|
||||
R"pb(max_queue_size: 10
|
||||
node {
|
||||
calculator: "CountingSourceCalculator"
|
||||
input_side_packet: "MAX_COUNT:max_count"
|
||||
input_side_packet: "BATCH_SIZE:batch_size"
|
||||
output_stream: "input_packets"
|
||||
}
|
||||
})");
|
||||
node {
|
||||
calculator: "PassThroughCalculator"
|
||||
input_stream: "input_packets"
|
||||
output_stream: "output_packets"
|
||||
input_stream_handler {
|
||||
input_stream_handler: "FixedSizeInputStreamHandler"
|
||||
}
|
||||
})pb");
|
||||
SetFixedMinSize(graph_config.mutable_node(1), GetParam());
|
||||
std::vector<Packet> output_packets;
|
||||
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
|
||||
@@ -220,7 +220,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
|
||||
TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
CalculatorGraphConfig graph_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(
|
||||
R"pb(
|
||||
input_stream: "in_0"
|
||||
input_stream: "in_1"
|
||||
input_stream: "in_2"
|
||||
@@ -241,7 +241,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
SetFixedMinSize(graph_config.mutable_node(0), GetParam());
|
||||
std::vector<Packet> output_packets[3];
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
@@ -289,7 +289,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) {
|
||||
CalculatorGraphConfig graph_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(
|
||||
R"pb(
|
||||
input_stream: "in_0"
|
||||
input_stream: "in_1"
|
||||
input_stream: "in_2"
|
||||
@@ -310,7 +310,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
SetFixedMinSize(graph_config.mutable_node(0), GetParam());
|
||||
std::vector<Packet> output_packets[3];
|
||||
std::string in_streams[3];
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace {
|
||||
// MuxInputStreamHandler should fail when running this test.
|
||||
TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input"
|
||||
node {
|
||||
calculator: "RoundRobinDemuxCalculator"
|
||||
@@ -75,7 +75,7 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
input_stream: "SELECT:select"
|
||||
output_stream: "OUTPUT:output"
|
||||
input_stream_handler { input_stream_handler: "MuxInputStreamHandler" }
|
||||
})");
|
||||
})pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace {
|
||||
// MuxInputStreamHandler should fail when running this test.
|
||||
TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input"
|
||||
node {
|
||||
calculator: "RoundRobinDemuxCalculator"
|
||||
@@ -82,7 +82,7 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
input_stream: "SELECT:select"
|
||||
output_stream: "OUTPUT:output"
|
||||
# MuxInputStreamHandler set in GetContract().
|
||||
})");
|
||||
})pb");
|
||||
CalculatorGraph graph;
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
@@ -195,7 +195,7 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
#define NUM_STREAMS 4
|
||||
CalculatorGraphConfig graph_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(
|
||||
R"pb(
|
||||
input_stream: "in_0"
|
||||
input_stream: "in_1"
|
||||
input_stream: "in_2"
|
||||
@@ -211,7 +211,7 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
output_stream: "out_2"
|
||||
output_stream: "out_3"
|
||||
# FixedSizeInputStreamHandler set in GetContract()
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> output_packets[NUM_STREAMS];
|
||||
for (int i = 0; i < NUM_STREAMS; ++i) {
|
||||
tool::AddVectorSink(absl::StrCat("out_", i), &graph_config,
|
||||
|
||||
@@ -84,7 +84,7 @@ absl::Status InputsToDebugString(const InputStreamShardSet& inputs,
|
||||
|
||||
TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
|
||||
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(
|
||||
R"(
|
||||
R"pb(
|
||||
input_stream: "a"
|
||||
input_stream: "b"
|
||||
input_stream: "c"
|
||||
@@ -123,7 +123,7 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
// The sync sets by stream name and CollectionItemId.
|
||||
// {a, c, e}, {b, d}, {f}, {g}, {h}
|
||||
// {0, 2, 4}, {1, 3}, {5}, {6}, {7}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace {
|
||||
|
||||
TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_video"
|
||||
input_stream: "input_camera"
|
||||
node {
|
||||
@@ -43,7 +43,7 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink_video, sink_camera;
|
||||
tool::AddVectorSink("output_video", &config, &sink_video);
|
||||
tool::AddVectorSink("output_camera", &config, &sink_camera);
|
||||
@@ -121,7 +121,7 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
|
||||
|
||||
TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_video"
|
||||
input_stream: "input_camera"
|
||||
node {
|
||||
@@ -139,7 +139,7 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})");
|
||||
})pb");
|
||||
std::vector<Packet> sink_video, sink_camera;
|
||||
tool::AddVectorSink("output_video", &config, &sink_video);
|
||||
tool::AddVectorSink("output_camera", &config, &sink_camera);
|
||||
|
||||
@@ -110,13 +110,13 @@ REGISTER_MEDIAPIPE_GRAPH(EmitSideServiceStringTestSubgraph);
|
||||
|
||||
TEST(SubgraphServicesTest, EmitStringFromTestService) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
output_side_packet: "str"
|
||||
node {
|
||||
calculator: "EmitSideServiceStringTestSubgraph"
|
||||
output_side_packet: "str"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
Packet side_string;
|
||||
tool::AddSidePacketSink("str", &config, &side_string);
|
||||
|
||||
@@ -22,15 +22,16 @@
|
||||
namespace mediapipe {
|
||||
|
||||
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeUnspecified) {
|
||||
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] { num_threads: 2 }
|
||||
}
|
||||
}
|
||||
)");
|
||||
CalculatorGraphConfig config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] { num_threads: 2 }
|
||||
}
|
||||
}
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
@@ -39,24 +40,25 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeUnspecified) {
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
|
||||
EXPECT_THAT(config, EqualsProto(expected_config));
|
||||
}
|
||||
|
||||
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeTooSmall) {
|
||||
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
num_threads: 2
|
||||
stack_size: 65536
|
||||
CalculatorGraphConfig config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
num_threads: 2
|
||||
stack_size: 65536
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
@@ -65,24 +67,14 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeTooSmall) {
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
|
||||
EXPECT_THAT(config, EqualsProto(expected_config));
|
||||
}
|
||||
|
||||
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeLargeEnough) {
|
||||
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
num_threads: 2
|
||||
stack_size: 262144
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
CalculatorGraphConfig expected_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
CalculatorGraphConfig config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
@@ -91,17 +83,29 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeLargeEnough) {
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
num_threads: 2
|
||||
stack_size: 262144
|
||||
}
|
||||
}
|
||||
}
|
||||
)pb");
|
||||
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
|
||||
EXPECT_THAT(config, EqualsProto(expected_config));
|
||||
}
|
||||
|
||||
TEST(GraphTest, MinimumDefaultExecutorStackSizeNumThreads) {
|
||||
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
num_threads: 1
|
||||
)");
|
||||
CalculatorGraphConfig config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
num_threads: 1
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
executor {
|
||||
options {
|
||||
[mediapipe.ThreadPoolExecutorOptions.ext] {
|
||||
@@ -110,7 +114,7 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeNumThreads) {
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
|
||||
EXPECT_THAT(config, EqualsProto(expected_config));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace {
|
||||
class SimulationClockTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUpInFlightGraph() {
|
||||
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_packets_0"
|
||||
node {
|
||||
calculator: 'FlowLimiterCalculator'
|
||||
@@ -84,7 +84,7 @@ class SimulationClockTest : public ::testing::Test {
|
||||
output_stream: 'output_packets_0'
|
||||
output_stream: 'finish_indicator'
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
}
|
||||
|
||||
// Initialize the test clock as a SimulationClock.
|
||||
@@ -246,7 +246,7 @@ TEST_F(SimulationClockTest, InFlight) {
|
||||
// and SimulationClock. With tsan, this test reveals a race condition unless
|
||||
// the SimulationClock destructor calls ThreadFinish to waits for all threads.
|
||||
TEST_F(SimulationClockTest, DestroyClock) {
|
||||
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "LambdaCalculator"
|
||||
input_side_packet: 'callback_0'
|
||||
@@ -258,7 +258,7 @@ TEST_F(SimulationClockTest, DestroyClock) {
|
||||
input_stream: "input_1"
|
||||
output_stream: "output_1"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
int input_count = 0;
|
||||
ProcessFunction wait_0 = [&](const InputStreamShardSet& inputs,
|
||||
|
||||
@@ -75,14 +75,14 @@ TEST(CallbackFromGeneratorTest, TestAddVectorSink) {
|
||||
|
||||
TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_packets"
|
||||
node {
|
||||
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
|
||||
input_stream: "input_packets"
|
||||
output_side_packet: "num_of_packets"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
|
||||
Packet summary_packet;
|
||||
tool::AddSidePacketSink("num_of_packets", &config, &summary_packet);
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& /*options*/) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "DATA:input_1"
|
||||
node {
|
||||
name: "regular_node"
|
||||
@@ -89,7 +89,7 @@ class TestSubgraph : public Subgraph {
|
||||
packet_generator: "SomePacketGenerator"
|
||||
output_side_packet: "side"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -100,7 +100,7 @@ class PacketFactoryTestSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& /*options*/) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "DATA:input_1"
|
||||
node {
|
||||
name: "regular_node"
|
||||
@@ -118,7 +118,7 @@ class PacketFactoryTestSubgraph : public Subgraph {
|
||||
packet_factory: "SomePacketFactory"
|
||||
output_side_packet: "side"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -157,7 +157,7 @@ class NodeWithExecutorSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& options) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "INPUT:foo"
|
||||
output_stream: "OUTPUT:bar"
|
||||
node {
|
||||
@@ -166,7 +166,7 @@ class NodeWithExecutorSubgraph : public Subgraph {
|
||||
output_stream: "bar"
|
||||
executor: "custom_thread_pool"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -179,7 +179,7 @@ class EnclosingSubgraph : public Subgraph {
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
const SubgraphOptions& options) override {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "IN:in"
|
||||
output_stream: "OUT:out"
|
||||
node {
|
||||
@@ -187,7 +187,7 @@ class EnclosingSubgraph : public Subgraph {
|
||||
input_stream: "INPUT:in"
|
||||
output_stream: "OUTPUT:out"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
return config;
|
||||
}
|
||||
};
|
||||
@@ -195,7 +195,7 @@ REGISTER_MEDIAPIPE_GRAPH(EnclosingSubgraph);
|
||||
|
||||
TEST(SubgraphExpansionTest, TransformStreamNames) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSinkCalculator"
|
||||
input_stream: "input_1"
|
||||
@@ -203,9 +203,9 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
|
||||
input_stream: "AUDIO:0:input_3"
|
||||
input_stream: "AUDIO:1:input_4"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSinkCalculator"
|
||||
input_stream: "input_1_foo"
|
||||
@@ -213,7 +213,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
|
||||
input_stream: "AUDIO:0:input_3_foo"
|
||||
input_stream: "AUDIO:1:input_4_foo"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
auto add_foo = [](absl::string_view s) { return absl::StrCat(s, "_foo"); };
|
||||
MP_EXPECT_OK(tool::TransformStreamNames(
|
||||
(*config.mutable_node())[0].mutable_input_stream(), add_foo));
|
||||
@@ -222,7 +222,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
|
||||
|
||||
TEST(SubgraphExpansionTest, TransformNames) {
|
||||
CalculatorGraphConfig config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_1"
|
||||
node {
|
||||
calculator: "SomeRegularCalculator"
|
||||
@@ -238,9 +238,9 @@ TEST(SubgraphExpansionTest, TransformNames) {
|
||||
input_stream: "output_1"
|
||||
output_stream: "output_2"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_config =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "__sg0_input_1"
|
||||
node {
|
||||
calculator: "SomeRegularCalculator"
|
||||
@@ -257,7 +257,7 @@ TEST(SubgraphExpansionTest, TransformNames) {
|
||||
input_stream: "__sg0_output_1"
|
||||
output_stream: "__sg0_output_2"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
auto add_prefix = [](absl::string_view s) {
|
||||
return absl::StrCat("__sg0_", s);
|
||||
};
|
||||
@@ -267,14 +267,14 @@ TEST(SubgraphExpansionTest, TransformNames) {
|
||||
|
||||
TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
|
||||
CalculatorGraphConfig config1 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_1"
|
||||
input_stream: "VIDEO:input_2"
|
||||
input_stream: "AUDIO:0:input_3"
|
||||
input_stream: "AUDIO:1:input_4"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig config2 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSubgraph"
|
||||
input_stream: "foo"
|
||||
@@ -282,7 +282,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
|
||||
input_stream: "AUDIO:0:baz"
|
||||
input_stream: "AUDIO:1:qux"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::map<std::string, std::string> stream_map;
|
||||
MP_EXPECT_OK(tool::FindCorrespondingStreams(
|
||||
&stream_map, config1.input_stream(), config2.node()[0].input_stream()));
|
||||
@@ -296,13 +296,13 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
|
||||
TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
|
||||
// The VIDEO tag does not exist in the subgraph.
|
||||
CalculatorGraphConfig config1 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_1"
|
||||
input_stream: "AUDIO:0:input_3"
|
||||
input_stream: "AUDIO:1:input_4"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig config2 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSubgraph"
|
||||
input_stream: "foo"
|
||||
@@ -310,7 +310,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
|
||||
input_stream: "AUDIO:0:baz"
|
||||
input_stream: "AUDIO:1:qux"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::map<std::string, std::string> stream_map;
|
||||
auto status = tool::FindCorrespondingStreams(
|
||||
&stream_map, config1.input_stream(), config2.node()[0].input_stream());
|
||||
@@ -326,13 +326,13 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
|
||||
TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
|
||||
// The AUDIO tag has too few indexes in the subgraph (1 vs. 2).
|
||||
CalculatorGraphConfig config1 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input_1"
|
||||
input_stream: "VIDEO:input_2"
|
||||
input_stream: "AUDIO:0:input_3"
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig config2 =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSubgraph"
|
||||
input_stream: "foo"
|
||||
@@ -340,7 +340,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
|
||||
input_stream: "AUDIO:0:baz"
|
||||
input_stream: "AUDIO:1:qux"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
std::map<std::string, std::string> stream_map;
|
||||
auto status = tool::FindCorrespondingStreams(
|
||||
&stream_map, config1.input_stream(), config2.node()[0].input_stream());
|
||||
@@ -355,7 +355,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
|
||||
|
||||
TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
|
||||
CalculatorGraphConfig subgraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "A:input_1"
|
||||
input_stream: "B:input_2"
|
||||
output_stream: "O:output_2"
|
||||
@@ -379,9 +379,9 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
|
||||
input_side_packet: "side_input"
|
||||
output_side_packet: "side_output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
calculator: "SomeSubgraph"
|
||||
input_stream: "A:foo"
|
||||
@@ -390,11 +390,11 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
|
||||
input_side_packet: "SI:flip"
|
||||
output_side_packet: "SO:flop"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
// Note: graph input streams, output streams, and side packets on the
|
||||
// subgraph are not changed because they are going to be discarded anyway.
|
||||
CalculatorGraphConfig expected_subgraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "A:input_1"
|
||||
input_stream: "B:input_2"
|
||||
output_stream: "O:output_2"
|
||||
@@ -418,23 +418,23 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
|
||||
input_side_packet: "flip"
|
||||
output_side_packet: "flop"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_EXPECT_OK(tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph));
|
||||
EXPECT_THAT(subgraph, mediapipe::EqualsProto(expected_subgraph));
|
||||
}
|
||||
|
||||
TEST(SubgraphExpansionTest, ExpandSubgraphs) {
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "simple_source"
|
||||
calculator: "SomeSourceCalculator"
|
||||
output_stream: "foo"
|
||||
}
|
||||
node { calculator: "TestSubgraph" input_stream: "DATA:foo" }
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "simple_source"
|
||||
calculator: "SomeSourceCalculator"
|
||||
@@ -456,14 +456,14 @@ TEST(SubgraphExpansionTest, ExpandSubgraphs) {
|
||||
packet_generator: "SomePacketGenerator"
|
||||
output_side_packet: "testsubgraph__side"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "simple_source"
|
||||
calculator: "SomeSourceCalculator"
|
||||
@@ -475,7 +475,7 @@ TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
|
||||
input_stream: "DATA:foo"
|
||||
buffer_size_hint: -1 # This field is only applicable to calculators.
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
absl::Status s1 = tool::ValidateSubgraphFields(supergraph.node(1));
|
||||
EXPECT_EQ(s1.code(), absl::StatusCode::kInvalidArgument);
|
||||
EXPECT_THAT(s1.message(), testing::HasSubstr("foo_subgraph"));
|
||||
@@ -491,7 +491,7 @@ TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
|
||||
// subgraph executor support in the future.
|
||||
TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input"
|
||||
executor {
|
||||
name: "custom_thread_pool"
|
||||
@@ -505,9 +505,9 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
|
||||
input_stream: "IN:input"
|
||||
output_stream: "OUT:output"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
CalculatorGraphConfig expected_graph = mediapipe::ParseTextProtoOrDie<
|
||||
CalculatorGraphConfig>(R"(
|
||||
CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "input"
|
||||
executor {
|
||||
name: "custom_thread_pool"
|
||||
@@ -523,7 +523,7 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
|
||||
output_stream: "output"
|
||||
executor: "custom_thread_pool"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
@@ -545,17 +545,17 @@ REGISTER_MEDIAPIPE_GRAPH(GraphServicesClientTestSubgraph);
|
||||
|
||||
TEST(SubgraphExpansionTest, GraphServicesUsage) {
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node { calculator: "GraphServicesClientTestSubgraph" }
|
||||
)");
|
||||
)pb");
|
||||
|
||||
CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "graphservicesclienttestsubgraph__ExpectedNode"
|
||||
calculator: "ExpectedNode"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
GraphServiceManager service_manager;
|
||||
MP_ASSERT_OK(service_manager.SetServiceObject(
|
||||
kStringTestService, std::make_shared<std::string>("ExpectedNode")));
|
||||
|
||||
@@ -67,7 +67,7 @@ REGISTER_CALCULATOR(TripleIntCalculator);
|
||||
// Note that the input and output tags supplied to the container node,
|
||||
// must match the input and output tags required by the subnodes.
|
||||
CalculatorGraphConfig SubnodeContainerExample() {
|
||||
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_stream: "foo"
|
||||
input_stream: "enable"
|
||||
input_side_packet: "timezone"
|
||||
@@ -90,14 +90,14 @@ CalculatorGraphConfig SubnodeContainerExample() {
|
||||
output_stream: "output_foo"
|
||||
output_stream: "output_bar"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
}
|
||||
|
||||
// A testing example of a SwitchContainer containing two subnodes.
|
||||
// Note that the side-input and side-output tags supplied to the container node,
|
||||
// must match the side-input and side-output tags required by the subnodes.
|
||||
CalculatorGraphConfig SideSubnodeContainerExample() {
|
||||
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "foo"
|
||||
input_side_packet: "enable"
|
||||
output_side_packet: "output_bar"
|
||||
@@ -120,7 +120,7 @@ CalculatorGraphConfig SideSubnodeContainerExample() {
|
||||
output_side_packet: "output_foo"
|
||||
output_side_packet: "output_bar"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
}
|
||||
|
||||
// Runs the test container graph with a few input packets.
|
||||
@@ -217,7 +217,7 @@ TEST(SwitchContainerTest, ApplyToSubnodes) {
|
||||
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
|
||||
CalculatorGraphConfig supergraph = SubnodeContainerExample();
|
||||
CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
node {
|
||||
name: "switchcontainer__SwitchDemuxCalculator"
|
||||
calculator: "SwitchDemuxCalculator"
|
||||
@@ -256,7 +256,7 @@ TEST(SwitchContainerTest, ApplyToSubnodes) {
|
||||
input_stream: "foo"
|
||||
input_stream: "enable"
|
||||
input_side_packet: "timezone"
|
||||
)");
|
||||
)pb");
|
||||
expected_graph = OrderNodes(expected_graph, {4, 0, 3, 1, 2});
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
@@ -275,7 +275,7 @@ TEST(SwitchContainerTest, ApplyToSideSubnodes) {
|
||||
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
|
||||
CalculatorGraphConfig supergraph = SideSubnodeContainerExample();
|
||||
CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "foo"
|
||||
input_side_packet: "enable"
|
||||
output_side_packet: "output_bar"
|
||||
@@ -314,7 +314,7 @@ TEST(SwitchContainerTest, ApplyToSideSubnodes) {
|
||||
output_side_packet: "output_foo"
|
||||
output_side_packet: "output_bar"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
expected_graph = OrderNodes(expected_graph, {4, 0, 3, 1, 2});
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
@@ -332,7 +332,7 @@ TEST(SwitchContainerTest, RunWithSideSubnodes) {
|
||||
TEST(SwitchContainerTest, ValidateSideInputs) {
|
||||
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
|
||||
CalculatorGraphConfig supergraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
input_side_packet: "foo"
|
||||
input_side_packet: "enable"
|
||||
output_side_packet: "output_bar"
|
||||
@@ -356,7 +356,7 @@ TEST(SwitchContainerTest, ValidateSideInputs) {
|
||||
output_side_packet: "output_foo"
|
||||
output_side_packet: "output_bar"
|
||||
}
|
||||
)");
|
||||
)pb");
|
||||
auto status = tool::ExpandSubgraphs(&supergraph);
|
||||
EXPECT_EQ(std::pair(status.code(), std::string(status.message())),
|
||||
std::pair(absl::StatusCode::kInvalidArgument,
|
||||
|
||||
Reference in New Issue
Block a user