Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run tests with GPU disabled #634

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,36 @@ public class ValidatedGraphConfigTest
output_stream: ""out""
";

private const string _ObjectronConfigText = @"
private const string _FlowLimiterConfigText = @"
input_stream: ""input_video""
input_stream: ""output""

node {
calculator: ""ObjectronGpuSubgraph""
input_stream: ""IMAGE_GPU:input_video""
input_side_packet: ""LABELS_CSV:allowed_labels""
input_side_packet: ""MAX_NUM_OBJECTS:max_num_objects""
output_stream: ""FRAME_ANNOTATION:lifted_objects""
output_stream: ""NORM_RECTS:multi_box_rects""
output_stream: ""MULTI_LANDMARKS:multi_box_landmarks""
}
calculator: ""FlowLimiterCalculator""
input_stream: ""input_video""
input_stream: ""FINISHED:output""
input_stream_info: {
tag_index: ""FINISHED""
back_edge: true
}
input_side_packet: ""MAX_IN_FLIGHT:max_in_flight""
input_side_packet: ""OPTIONS:flow_limiter_calculator_options""
output_stream: ""throttled_input_video""
}
";
private const string _PoseLandmarkConfigText = @"

private const string _ImageTransformationConfigText = @"
input_stream: ""input_video""

node {
calculator: ""PoseLandmarkGpu""
node: {
calculator: ""ImageTransformationCalculator""
input_stream: ""IMAGE:input_video""
input_side_packet: ""MODEL_COMPLEXITY:model_complexity""
input_side_packet: ""SMOOTH_LANDMARKS:smooth_landmarks""
output_stream: ""LANDMARKS:pose_landmarks""
output_stream: ""WORLD_LANDMARKS:pose_world_landmarks""
output_stream: ""DETECTION:pose_detection""
output_stream: ""ROI_FROM_LANDMARKS:roi_from_landmarks""
}";
input_side_packet: ""ROTATION_DEGREES:input_rotation""
input_side_packet: ""FLIP_HORIZONTALLY:input_horizontally_flipped""
input_side_packet: ""FLIP_VERTICALLY:input_vertically_flipped""
output_stream: ""IMAGE:transformed_input_video""
}
";

private const string _ConstantSidePacketConfigText = @"
node {
Expand All @@ -69,6 +73,18 @@ public class ValidatedGraphConfigTest
}
}
}
";

private const string _FaceDetectionShortRangeCommonConfigText = @"
input_stream: ""detection_tensors""
input_stream: ""transform_matrix""

node {
calculator: ""FaceDetectionShortRangeCommon""
input_stream: ""TENSORS:detection_tensors""
input_stream: ""MATRIX:transform_matrix""
output_stream: ""DETECTIONS:detections""
}
";

#region Constructor
Expand Down Expand Up @@ -183,7 +199,7 @@ public void ValidateRequiredSidePackets_ShouldReturnOk_When_AllTheSidePacketsAre
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_PoseLandmarkConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_FlowLimiterConfigText)).AssertOk();
using (var sidePacket = new SidePacket())
{
using (var status = config.ValidateRequiredSidePackets(sidePacket))
Expand All @@ -199,7 +215,7 @@ public void ValidateRequiredSidePackets_ShouldReturnInvalidArgumentError_When_Th
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ObjectronConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ImageTransformationConfigText)).AssertOk();
using (var sidePacket = new SidePacket())
{
using (var status = config.ValidateRequiredSidePackets(sidePacket))
Expand All @@ -215,10 +231,11 @@ public void ValidateRequiredSidePackets_ShouldReturnInvalidArgumentError_When_Al
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ObjectronConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ImageTransformationConfigText)).AssertOk();
using (var sidePacket = new SidePacket())
{
sidePacket.Emplace("max_num_objects", new IntPacket(3));
sidePacket.Emplace("input_horizontally_flipped", new BoolPacket(false));
sidePacket.Emplace("input_vertically_flipped", new BoolPacket(true));
using (var status = config.ValidateRequiredSidePackets(sidePacket))
{
Assert.AreEqual(Status.StatusCode.InvalidArgument, status.Code());
Expand All @@ -232,11 +249,12 @@ public void ValidateRequiredSidePackets_ShouldReturnInvalidArgumentError_When_Th
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ObjectronConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ImageTransformationConfigText)).AssertOk();
using (var sidePacket = new SidePacket())
{
sidePacket.Emplace("allowed_labels", new StringPacket("cup"));
sidePacket.Emplace("max_num_objects", new StringPacket("3"));
sidePacket.Emplace("input_horizontally_flipped", new BoolPacket(false));
sidePacket.Emplace("input_vertically_flipped", new BoolPacket(true));
sidePacket.Emplace("input_rotation", new StringPacket("0"));
using (var status = config.ValidateRequiredSidePackets(sidePacket))
{
Assert.AreEqual(Status.StatusCode.InvalidArgument, status.Code());
Expand All @@ -250,11 +268,12 @@ public void ValidateRequiredSidePackets_ShouldReturnOk_When_AllTheRequiredSidePa
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ObjectronConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_ImageTransformationConfigText)).AssertOk();
using (var sidePacket = new SidePacket())
{
sidePacket.Emplace("allowed_labels", new StringPacket("cup"));
sidePacket.Emplace("max_num_objects", new IntPacket(3));
sidePacket.Emplace("input_horizontally_flipped", new BoolPacket(false));
sidePacket.Emplace("input_vertically_flipped", new BoolPacket(true));
sidePacket.Emplace("input_rotation", new IntPacket(0));
using (var status = config.ValidateRequiredSidePackets(sidePacket))
{
Assert.True(status.Ok());
Expand Down Expand Up @@ -297,16 +316,16 @@ public void Config_ShouldReturnTheCanonicalizedConfig_When_TheConfigIsPassThroug
}

[Test]
public void Config_ShouldReturnTheCanonicalizedConfig_When_TheConfigIsPoseLandmarkConfig()
public void Config_ShouldReturnTheCanonicalizedConfig_When_TheConfigIsFaceDetectionShortRangeCommonConfig()
{
using (var config = new ValidatedGraphConfig())
{
var originalConfig = CalculatorGraphConfig.Parser.ParseFromTextFormat(_PoseLandmarkConfigText);
var originalConfig = CalculatorGraphConfig.Parser.ParseFromTextFormat(_FaceDetectionShortRangeCommonConfigText);
config.Initialize(originalConfig).AssertOk();
var canonicalizedConfig = config.Config();

Assert.AreEqual(251, originalConfig.CalculateSize());
Assert.AreEqual(26514, canonicalizedConfig.CalculateSize());
Assert.AreEqual(145, originalConfig.CalculateSize());
Assert.AreEqual(936, canonicalizedConfig.CalculateSize());
}
}
#endregion
Expand Down Expand Up @@ -422,20 +441,20 @@ public void InputSidePacketInfos_ShouldReturnEdgeInfoList_When_InputSidePacketsE
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_PoseLandmarkConfigText)).AssertOk();
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_FlowLimiterConfigText)).AssertOk();
var inputSidePacketInfos = config.InputSidePacketInfos();

Assert.True(inputSidePacketInfos.Count >= 2);

var modelComplexityPacket = inputSidePacketInfos.First((edgeInfo) => edgeInfo.name == "model_complexity");
Assert.AreEqual(-1, modelComplexityPacket.upstream);
Assert.AreEqual(NodeType.Calculator, modelComplexityPacket.parentNode.type);
Assert.False(modelComplexityPacket.backEdge);
var maxInFlightPacket = inputSidePacketInfos.First((edgeInfo) => edgeInfo.name == "max_in_flight");
Assert.AreEqual(-1, maxInFlightPacket.upstream);
Assert.AreEqual(NodeType.Calculator, maxInFlightPacket.parentNode.type);
Assert.False(maxInFlightPacket.backEdge);

var smoothLandmarksPacket = inputSidePacketInfos.First((edgeInfo) => edgeInfo.name == "smooth_landmarks");
Assert.AreEqual(-1, smoothLandmarksPacket.upstream);
Assert.AreEqual(NodeType.Calculator, smoothLandmarksPacket.parentNode.type);
Assert.False(smoothLandmarksPacket.backEdge);
var flowLimiterCalculatorOptionsPacket = inputSidePacketInfos.First((edgeInfo) => edgeInfo.name == "flow_limiter_calculator_options");
Assert.AreEqual(-1, flowLimiterCalculatorOptionsPacket.upstream);
Assert.AreEqual(NodeType.Calculator, flowLimiterCalculatorOptionsPacket.parentNode.type);
Assert.False(flowLimiterCalculatorOptionsPacket.backEdge);
}
}
#endregion
Expand Down Expand Up @@ -603,7 +622,7 @@ public void RegisteredSidePacketTypeName_ShouldReturnInvalidArgumentError_When_T
{
using (var config = new ValidatedGraphConfig())
{
using (var statusOrString = config.RegisteredSidePacketTypeName("model_complexity"))
using (var statusOrString = config.RegisteredSidePacketTypeName("max_in_flight"))
{
Assert.AreEqual(Status.StatusCode.InvalidArgument, statusOrString.status.Code());
}
Expand All @@ -615,8 +634,8 @@ public void RegisteredSidePacketTypeName_ShouldReturnUnknownError_When_TheSidePa
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_PoseLandmarkConfigText)).AssertOk();
using (var statusOrString = config.RegisteredSidePacketTypeName("model_complexity"))
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_FlowLimiterConfigText)).AssertOk();
using (var statusOrString = config.RegisteredSidePacketTypeName("max_in_flight"))
{
Assert.AreEqual(Status.StatusCode.Unknown, statusOrString.status.Code());
}
Expand Down Expand Up @@ -694,7 +713,7 @@ public void IsExternalSidePacket_ShouldReturnFalse_When_NotInitialized()
{
using (var config = new ValidatedGraphConfig())
{
Assert.False(config.IsExternalSidePacket("model_complexity"));
Assert.False(config.IsExternalSidePacket("max_in_flight"));
}
}

Expand All @@ -714,8 +733,8 @@ public void IsExternalSidePacket_ShouldReturnTrue_When_TheSidePacketIsExternal()
{
using (var config = new ValidatedGraphConfig())
{
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_PoseLandmarkConfigText)).AssertOk();
Assert.True(config.IsExternalSidePacket("model_complexity"));
config.Initialize(CalculatorGraphConfig.Parser.ParseFromTextFormat(_FlowLimiterConfigText)).AssertOk();
Assert.True(config.IsExternalSidePacket("max_in_flight"));
}
}
#endregion
Expand Down