From 8803f6fff445934afdded590f81fddae2bfe0868 Mon Sep 17 00:00:00 2001 From: shahasad <43590019+shahasad@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:23:43 -0700 Subject: [PATCH] C# end to end test fix, and make end to end tests mandatory (#2079) --- .../InferenceTest.cs | 82 ++++++++++++++++++- .../nuget/templates/test_win.yml | 6 -- 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index 47c756c2d7..78cb0bd6e6 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -1058,6 +1058,86 @@ namespace Microsoft.ML.OnnxRuntime.Tests return tensorData.ToArray(); } + + private enum TensorElementType + { + Float = 1, + UInt8 = 2, + Int8 = 3, + UInt16 = 4, + Int16 = 5, + Int32 = 6, + Int64 = 7, + String = 8, + Bool = 9, + Float16 = 10, + Double = 11, + UInt32 = 12, + UInt64 = 13, + Complex64 = 14, + Complex128 = 15, + BFloat16 = 16, + DataTypeMax = 17 + } + + private static void GetTypeAndWidth(TensorElementType elemType, out Type type, out int width) + { + switch (elemType) + { + case TensorElementType.Float: + type = typeof(float); + width = sizeof(float); + break; + case TensorElementType.Double: + type = typeof(double); + width = sizeof(double); + break; + case TensorElementType.Int16: + type = typeof(short); + width = sizeof(short); + break; + case TensorElementType.UInt16: + type = typeof(ushort); + width = sizeof(ushort); + break; + case TensorElementType.Int32: + type = typeof(int); + width = sizeof(int); + break; + case TensorElementType.UInt32: + type = typeof(uint); + width = sizeof(uint); + break; + case TensorElementType.Int64: + type = typeof(long); + width = sizeof(long); + break; + case TensorElementType.UInt64: + type = typeof(ulong); + width = sizeof(ulong); + break; + case TensorElementType.UInt8: + type = typeof(byte); + width = sizeof(byte); + break; + case TensorElementType.Int8: + type = typeof(sbyte); + width = sizeof(sbyte); + break; + case TensorElementType.String: + type = typeof(byte); + width = sizeof(byte); + break; + case TensorElementType.Bool: + type = typeof(bool); + width = sizeof(bool); + break; + default: + type = null; + width = 0; + break; + } + } static NamedOnnxValue LoadTensorFromFilePb(string filename, IReadOnlyDictionary nodeMetaDict) { var file = File.OpenRead(filename); @@ -1066,7 +1146,7 @@ namespace Microsoft.ML.OnnxRuntime.Tests Type tensorElemType = null; int width = 0; - TensorElementTypeConverter.GetTypeAndWidth((TensorElementType)tensor.DataType, out tensorElemType, out width); + GetTypeAndWidth((TensorElementType)tensor.DataType, out tensorElemType, out width); var intDims = new int[tensor.Dims.Count]; for (int i = 0; i < tensor.Dims.Count; i++) { diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml index 0615dd9b6f..1b74b818d9 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml @@ -38,7 +38,6 @@ jobs: test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact netcoreapp2.1 x64 $(NuGetPackageVersionNumber) workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C#) .Net Core' - continueOnError: true - script: | @echo "Running Runtest.bat" @@ -46,14 +45,12 @@ jobs: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C#) .Net Core x86' enabled: false - continueOnError: true - script: | @echo "Running Runtest.bat" test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact net461 x64 $(NuGetPackageVersionNumber) workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C#) .NetFramework' - continueOnError: true - script: | @echo "Running Runtest.bat" @@ -61,7 +58,6 @@ jobs: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C#) .NetFramework x86' enabled: false - continueOnError: true - script: | @echo "Running runtest.bat" @@ -73,7 +69,6 @@ jobs: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C-API) ' timeoutInMinutes: 30 - continueOnError: true # test C++ API sample - script: | @@ -89,7 +84,6 @@ jobs: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Run End to End Test (C++ API) ' timeoutInMinutes: 30 - continueOnError: true - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection'