Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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
Comment thread
skyline75489 marked this conversation as resolved.

- 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
Comment thread
skyline75489 marked this conversation as resolved.
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 @@ -106,7 +102,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 @@ -148,7 +144,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 @@ -191,7 +187,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 @@ -230,7 +226,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 @@ -259,7 +255,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 @@ -290,7 +286,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 @@ -326,7 +322,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 @@ -350,7 +346,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