From d7f2cdcc7ef8ef95a2d3d2af9d3c528256162471 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Mon, 24 Feb 2020 23:02:59 -0800 Subject: [PATCH] Fix target platform of managed OnnxRuntime dll and enable x86 .NET testing (#3056) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIP: Re-enable x86 .NET testing in Release pipelines Enabling x86 testing will make sure that ORT packages doesn’t break x86 projects of customers * Remove setting some env variables * Comment out a test failing on x86 builds * More changes * Minor fix * More changes * More changes * s * s * s * Revert minor change * More changes * More changes * More changes 2 * explicitly set platform target * Delete bin and obj folders * Clean output dirs * Add back TargetFramwork * Disable x86 .net framework tests * Skip x86 tests in MKLML pipeline --- ...rosoft.ML.OnnxRuntime.EndToEndTests.csproj | 1 - .../runtest.bat | 12 ++++++- .../InferenceTest.cs | 14 +++++++- .../nuget/templates/cpu-mklml.yml | 2 ++ .../azure-pipelines/nuget/templates/gpu.yml | 2 ++ .../nuget/templates/test_all_os.yml | 4 +++ .../nuget/templates/test_win.yml | 36 +++++++++++-------- .../azure-pipelines/templates/win-ci-2019.yml | 2 -- 8 files changed, 54 insertions(+), 19 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj index dbbc528eb4..bc9098e8a8 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj @@ -1,7 +1,6 @@  netcoreapp2.1 - win-x64 false $(MSBuildThisFileDirectory)..\.. AnyCPU diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat index 93a863b985..ae64e93273 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat @@ -17,6 +17,11 @@ IF NOT "%4"=="" ( echo "Usage: runtest.bat LocalNuGetRepoPath TargetFramework TargetArch NuGetPackageVersion" ) +IF "%TargetArch%"=="x64" ( + SET RuntimeIdentifier=win-x64 + SET PlatformTarget=x64 +) + IF "%TargetArch%"=="x86" ( SET dn="C:\Program Files (x86)\dotnet\dotnet" SET RuntimeIdentifier=win-x86 @@ -28,8 +33,13 @@ ECHO Target Framework is %TargetFramework% REM Update if CUDA lib paths if set SET PATH=%CUDA_PATH%\bin;%CUDNN_PATH%\bin;%PATH% +IF EXIST test\Microsoft.ML.OnnxRuntime.EndToEndTests\packages RMDIR /S /Q test\Microsoft.ML.OnnxRuntime.EndToEndTests\packages +IF EXIST test\Microsoft.ML.OnnxRuntime.EndToEndTests\bin RMDIR /S /Q test\Microsoft.ML.OnnxRuntime.EndToEndTests\bin +IF EXIST test\Microsoft.ML.OnnxRuntime.EndToEndTests\obj RMDIR /S /Q test\Microsoft.ML.OnnxRuntime.EndToEndTests\obj + @echo %CurrentOnnxRuntimeVersion% -%dn% restore test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --configfile .\Nuget.CSharp.config --no-cache --packages test\Microsoft.ML.OnnxRuntime.EndToEndTests --source https://api.nuget.org/v3/index.json --source %LocalNuGetRepo% +%dn% clean test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj +%dn% restore test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --configfile .\Nuget.CSharp.config --no-cache --packages test\Microsoft.ML.OnnxRuntime.EndToEndTests\packages --source https://api.nuget.org/v3/index.json --source %LocalNuGetRepo% IF NOT errorlevel 0 ( @echo "Failed to restore nuget packages for the test project" diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index 7b221f5e33..421d63977e 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -577,7 +577,7 @@ namespace Microsoft.ML.OnnxRuntime.Tests } } - [Fact] + [SkipNonPackageTests] private void TestRegisterCustomOpLibrary() { using (var option = new SessionOptions()) @@ -1461,5 +1461,17 @@ namespace Microsoft.ML.OnnxRuntime.Tests } } + private class SkipNonPackageTests : FactAttribute + { + public SkipNonPackageTests() + { + var skipNonPackageTests = System.Environment.GetEnvironmentVariable("SKIPNONPACKAGETESTS"); + if (skipNonPackageTests != null && skipNonPackageTests.Equals("ON")) + { + Skip = "Test skipped while testing the package as it is not within the scope"; + } + } + } + } } diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/cpu-mklml.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/cpu-mklml.yml index bea8aede66..cfcc9db3af 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/cpu-mklml.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/cpu-mklml.yml @@ -173,3 +173,5 @@ jobs: targetPath: '$(Build.ArtifactStagingDirectory)' - template: test_all_os.yml + parameters: + Skipx86Tests: 'true' diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml index d1ac975029..cfb0785efa 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml @@ -126,6 +126,8 @@ jobs: - template: test_win.yml parameters: AgentPool : 'Win-GPU-2019' + Skipx86Tests: 'true' + - template: test_linux.yml parameters: AgentPool : $(AgentPoolLinux) diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_all_os.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_all_os.yml index 1eac74b5fa..3a111b2f88 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_all_os.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_all_os.yml @@ -1,8 +1,12 @@ # test NuGet package on Win, Linux and MacOS +parameters: + Skipx86Tests: 'false' + jobs: - template: test_win.yml parameters: AgentPool : 'Win-CPU-2019' + Skipx86Tests : ${{ parameters.Skipx86Tests }} - template: test_linux.yml parameters: AgentPool : $(AgentPoolLinux) 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 93b11c2a19..10da77354d 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 @@ -1,5 +1,6 @@ parameters: AgentPool : 'Win-CPU' + Skipx86Tests: 'false' jobs: - job: NuGet_Test_Win @@ -13,6 +14,8 @@ jobs: - group: ORT_TEST_DATA_SAS - name: OnnxRuntimeBuildDirectory value: '$(Build.BinariesDirectory)' + - name: SKIPNONPACKAGETESTS + value: 'ON' steps: - task: UsePythonVersion@0 @@ -59,31 +62,36 @@ jobs: parameters: packageFolder: '$(Build.BinariesDirectory)\nuget-artifact' + # TODO: Add .Net Core AnyCPU test task + - script: | @echo "Running Runtest.bat" 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' + displayName: 'Run End to End Test (C#) .Net Core x64' - - script: | - @echo "Running Runtest.bat" - test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact netcoreapp2.1 x86 $(NuGetPackageVersionNumber) - workingDirectory: '$(Build.SourcesDirectory)\csharp' - displayName: 'Run End to End Test (C#) .Net Core x86' - enabled: false + - ${{ if ne(parameters['Skipx86Tests'], 'true') }}: + - script: | + @echo "Running Runtest.bat" + test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact netcoreapp2.1 x86 $(NuGetPackageVersionNumber) + workingDirectory: '$(Build.SourcesDirectory)\csharp' + displayName: 'Run End to End Test (C#) .Net Core x86' + + # TODO: Add .Net Framework AnyCPU test task - 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' + displayName: 'Run End to End Test (C#) .NetFramework x64' - - script: | - @echo "Running Runtest.bat" - test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact net461 x86 $(NuGetPackageVersionNumber) - workingDirectory: '$(Build.SourcesDirectory)\csharp' - displayName: 'Run End to End Test (C#) .NetFramework x86' - enabled: false + - ${{ if ne(parameters['Skipx86Tests'], 'true') }}: + - script: | + @echo "Running Runtest.bat" + test\Microsoft.ML.OnnxRuntime.EndToEndTests\runtest.bat $(Build.BinariesDirectory)\nuget-artifact net461 x86 $(NuGetPackageVersionNumber) + workingDirectory: '$(Build.SourcesDirectory)\csharp' + displayName: 'Run End to End Test (C#) .NetFramework x86' + enabled: false - script: | @echo "Running runtest.bat" diff --git a/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml b/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml index 04cdc56962..8c9d2a8784 100644 --- a/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml +++ b/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml @@ -30,8 +30,6 @@ jobs: DotNetExe: 'dotnet.exe' CUDA_VERSION: ${{ parameters.CudaVersion }} DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - PlatformTarget: ${{ parameters.BuildArch }} - RuntimeIdentifier: win-${{ parameters.BuildArch }} steps: - powershell: |