Skip to content

Commit

Permalink
Fix C# phi-2 test (#1050)
Browse files Browse the repository at this point in the history
The C# phi-2 test was skipped due to the wrong model path. This PR
intends to fix it.
  • Loading branch information
skyline75489 authored and ajindal1 committed Nov 21, 2024
1 parent 0ae77b4 commit 6bb21e7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-cpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
run: |
export ORTGENAI_LOG_ORT_LIB=1
cd test/csharp
dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/" /p:OrtLibDir="../../ort/lib/"
dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/" /p:OrtLibDir="../../ort/lib/" --verbosity normal
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mac-cpu-arm64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
run: |
export ORTGENAI_LOG_ORT_LIB=1
cd test/csharp
dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/osx-arm64"
dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/osx-arm64" --verbosity normal
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win-cpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Build the C# API and Run the C# Tests
run: |
cd test\csharp
dotnet test /p:NativeBuildOutputDir="$env:GITHUB_WORKSPACE\$env:binaryDir\Release" /p:OrtLibDir="$env:GITHUB_WORKSPACE\ort\lib"
dotnet test /p:NativeBuildOutputDir="$env:GITHUB_WORKSPACE\$env:binaryDir\Release" /p:OrtLibDir="$env:GITHUB_WORKSPACE\ort\lib" --verbosity normal
- name: Verify Build Artifacts
if: always()
Expand Down
38 changes: 17 additions & 21 deletions test/csharp/TestOnnxRuntimeGenAIAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,24 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.ML.OnnxRuntimeGenAI.Tests
{
public class TestsFixture : IDisposable
public class OnnxRuntimeGenAITests
{
private OgaHandle _handle;
public TestsFixture()
{
_handle = new OgaHandle();
}
private readonly ITestOutputHelper output;

public void Dispose()
// From https://stackoverflow.com/a/47841442
private static string GetThisFilePath([CallerFilePath] string path = null)
{
_handle.Dispose();
return path;
}
}

public class OnnxRuntimeGenAITests : IClassFixture<TestsFixture>
{
private readonly ITestOutputHelper output;
private static readonly string _phi2Path = Path.GetFullPath(Path.Combine(
GetThisFilePath(),"../..", "test_models", "phi-2", "int4", "cpu"));

public OnnxRuntimeGenAITests(ITestOutputHelper o)
{
Expand All @@ -37,7 +33,7 @@ private class IgnoreOnModelAbsenceFact : FactAttribute
{
public IgnoreOnModelAbsenceFact()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
bool exists = System.IO.Directory.Exists(modelPath);
if (!System.IO.Directory.Exists(modelPath))
{
Expand Down Expand Up @@ -125,7 +121,7 @@ public void TestTopKSearch()
float temp = 0.6f;
ulong maxLength = 20;

string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -167,7 +163,7 @@ public void TestTopPSearch()
float temp = 0.6f;
ulong maxLength = 20;

string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -210,7 +206,7 @@ public void TestTopKTopPSearch()
float temp = 0.6f;
ulong maxLength = 20;

string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -249,7 +245,7 @@ public void TestTopKTopPSearch()
[IgnoreOnModelAbsenceFact(DisplayName = "TestTokenizerBatchEncodeDecode")]
public void TestTokenizerBatchEncodeDecode()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -278,7 +274,7 @@ public void TestTokenizerBatchEncodeDecode()
[IgnoreOnModelAbsenceFact(DisplayName = "TestTokenizerBatchEncodeSingleDecode")]
public void TestTokenizerBatchEncodeSingleDecode()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -309,7 +305,7 @@ public void TestTokenizerBatchEncodeSingleDecode()
[IgnoreOnModelAbsenceFact(DisplayName = "TestTokenizerBatchEncodeStreamDecode")]
public void TestTokenizerBatchEncodeStreamDecode()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down Expand Up @@ -345,7 +341,7 @@ public void TestTokenizerBatchEncodeStreamDecode()
[IgnoreOnModelAbsenceFact(DisplayName = "TestTokenizerSingleEncodeDecode")]
public void TestTokenizerSingleEncodeDecode()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand All @@ -369,7 +365,7 @@ public void TestTokenizerSingleEncodeDecode()
[IgnoreOnModelAbsenceFact(DisplayName = "TestPhi2")]
public void TestPhi2()
{
string modelPath = Path.Combine(Directory.GetCurrentDirectory(), "test_models", "cpu", "phi-2");
string modelPath = _phi2Path;
using (var model = new Model(modelPath))
{
Assert.NotNull(model);
Expand Down

0 comments on commit 6bb21e7

Please sign in to comment.