Skip to content

Commit

Permalink
add ioinfo unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Mar 21, 2024
1 parent acbb5ff commit 2b62722
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build/00-common.linq
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static ProjectVersion[] Projects = new[]
new ProjectVersion("Sdcb.Onnx", "1.11.22.423"), // 1.11.22.423
new ProjectVersion("Sdcb.Mkldnn", "0.19"), // 0.19
new ProjectVersion("Sdcb.Paddle2Onnx", "1.0.0.2"), // 1.0.0-rc.2
new ProjectVersion("Sdcb.PaddleInference", "2.5.1"),
new ProjectVersion("Sdcb.PaddleInference", "2.6.0-preview.2"),
new ProjectVersion("Sdcb.PaddleOCR", "2.7.0.1"),
new ProjectVersion("Sdcb.PaddleOCR.Models.Online", "2.7.0.1"),
new ProjectVersion("Sdcb.PaddleOCR.Models.Shared", "2.7.0.1"),
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.PaddleInference/Native/PaddleStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal unsafe struct PD_Cstr

public override readonly string ToString()
{
return Data.ANSIToString((int)Size)!;
return Data.ANSIToString((int)Size - 1)!;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Sdcb.PaddleInference/PaddleIOInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public record PaddleIOInfo
/// Gets or init the data type of the input/output tensor.
/// </summary>
public required PaddleDataType DataType { get; init; }

/// <summary>
/// Text representation of the input/output tensor.
/// </summary>
public override string ToString() => $"{Name}: {DataType} [{string.Join(",", Shape)}]";
}
37 changes: 37 additions & 0 deletions tests/Sdcb.PaddleInference.Tests/IOInfoTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Sdcb.PaddleOCR.Models.Details;
using Sdcb.PaddleOCR.Models.Online;
using Xunit.Abstractions;

namespace Sdcb.PaddleInference.Tests;

public class IOInfoTests
{
private readonly ITestOutputHelper _console;

public IOInfoTests(ITestOutputHelper console)
{
_console = console;
}

[Fact]
public async Task CanDumpIOInfo()
{
FileDetectionModel model = await OnlineDetectionModel.ChineseV4.DownloadAsync();
using PaddleConfig c = PaddleConfig.FromModelDir(model.DirectoryPath);
using PaddlePredictor p = c.CreatePredictorNoDelete();

_console.WriteLine("Input infos:");
PaddleIOInfo[] inputInfos = p.InputInfos;
foreach (PaddleIOInfo info in inputInfos)
{
_console.WriteLine(info.ToString());
}

_console.WriteLine("Output infos:");
PaddleIOInfo[] outputInfos = p.OutputInfos;
foreach (PaddleIOInfo info in outputInfos)
{
_console.WriteLine(info.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1-preview.1" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sdcb.PaddleInference\Sdcb.PaddleInference.csproj" />
<ProjectReference Include="..\..\src\Sdcb.PaddleOCR.Models.Online\Sdcb.PaddleOCR.Models.Online.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/Sdcb.PaddleOCR.Tests/OnlineModelsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task V4FastCheckOCR()
}
}

[Fact]
[Fact(Skip = "Too slow")]
public async Task V4ServerTest()
{
OnlineFullModels onlineModels = OnlineFullModels.ChineseServerV4;
Expand Down

0 comments on commit 2b62722

Please sign in to comment.