From fdb4a3a2e887aeea235e6750add70202e307ebde Mon Sep 17 00:00:00 2001 From: Sheil Kumar Date: Tue, 7 Jul 2020 09:36:42 -0700 Subject: [PATCH] Add cppwinrt and cswinrt tests in windowsai nuget pipeline (#4381) * build e2e cppwinrt tests * add use nuget task * make all referenced to package version prop/target-ified * remove dupe props/targets reference * work around project.assets.json error by deleting it * powershell test invocation * switch to batch script * print debug info * update x86->x64 * stdio.h * pushd/popd * add csharp tests * package.config -> packages.config * typo * x86 -> anycpu * debug is default * add test path * update csproj as well * debug * really replace all package versions * debug output * really use [PackageVersion] * sleep intead of converting async operation to task and waiting * dont close software bitmap * switch to powershell script * remove binding check * continue on failure * continuse on error action * continueOnError and errorActionPreference * tabbing Co-authored-by: Sheil Kumar --- .../.gitignore | 4 + ...oft.AI.MachineLearning.Tests.CSharp.csproj | 111 ++++++++++++++++ ....AI.MachineLearning.Tests.CSharp.csproj.pp | 111 ++++++++++++++++ .../main.cs | 92 ++++++++++++++ .../packages.config | 6 + .../packages.config.pp | 6 + .../.gitignore | 4 + .../Microsoft.AI.MachineLearning.Tests.props | 6 + ...icrosoft.AI.MachineLearning.Tests.props.pp | 6 + ...Microsoft.AI.MachineLearning.Tests.vcxproj | 118 +++++++++++++++++ .../main.cpp | 56 ++++++++ .../nuget/templates/windowsai.yml | 120 ++++++++++++++++++ winml/lib/Api/LearningModelBinding.cpp | 1 - 13 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/main.cs create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config.pp create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props.pp create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.vcxproj create mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore new file mode 100644 index 0000000000..b05d286e48 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore @@ -0,0 +1,4 @@ +# build, distribute, and bins (+ python proto bindings) +Debug +x64 +packages \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj new file mode 100644 index 0000000000..990dc65f90 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj @@ -0,0 +1,111 @@ + + + + + + Debug + AnyCPU + {717C645E-9C4A-4EBF-A0AF-676B265E8CDA} + Exe + Microsoft.AI.MachineLearning.Tests.CSharp + Microsoft.AI.MachineLearning.Tests.CSharp + v4.7.2 + 512 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + + packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll + + + packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll + + + + + + + + + + + packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\lib\netstandard2.0\winrt.runtime.dll + + + + + + + + + + + Always + true + + + + + Always + true + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp new file mode 100644 index 0000000000..b0dd62e91a --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp @@ -0,0 +1,111 @@ + + + + + + Debug + AnyCPU + {717C645E-9C4A-4EBF-A0AF-676B265E8CDA} + Exe + Microsoft.AI.MachineLearning.Tests.CSharp + Microsoft.AI.MachineLearning.Tests.CSharp + v4.7.2 + 512 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + + packages\Microsoft.AI.MachineLearning.[PackageVersion]\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll + + + packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll + + + + + + + + + + + packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\lib\netstandard2.0\winrt.runtime.dll + + + + + + + + + + + Always + true + + + + + Always + true + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/main.cs b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/main.cs new file mode 100644 index 0000000000..1c86164698 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/main.cs @@ -0,0 +1,92 @@ +using System; +using System.IO; + +using Microsoft.AI.MachineLearning; +using WinRT; + +namespace Microsoft.AI.MachineLearning.Tests +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Load squeezenet.onnx."); + using (var model = LearningModel.LoadFromFilePath("squeezenet.onnx")) + { + Console.WriteLine("Load kitten_224.png as StorageFile."); + var name = AppDomain.CurrentDomain.BaseDirectory + "kitten_224.png"; + var image_task = Windows.Storage.StorageFile.GetFileFromPathAsync(name); + image_task.AsTask().Wait(); + var image = image_task.GetResults(); + Console.WriteLine("Load StorageFile into Stream."); + var stream_task = image.OpenReadAsync(); + System.Threading.Thread.Sleep(1000); + // stream_task.AsTask().Wait(); + // + // Unable to call AsTask on IAsyncOperation... + // System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.' + // This exception was originally thrown at this call stack: + // System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType) + // System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[]) + // System.RuntimeType.MakeGenericType(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[]) + // ABI.Windows.Foundation.AsyncOperationCompletedHandler.AsyncOperationCompletedHandler() + // + // So sleep instead... + using (var stream = stream_task.GetResults()) + { + Console.WriteLine("Create SoftwareBitmap from decoded Stream."); + var decoder_task = Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream); + System.Threading.Thread.Sleep(1000); + // decoder_task.AsTask().Wait(); + // + // Unable to call AsTask on IAsyncOperation... + // System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.' + // This exception was originally thrown at this call stack: + // System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType) + // System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[]) + // System.RuntimeType.MakeGenericType(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[]) + // ABI.Windows.Foundation.AsyncOperationCompletedHandler.AsyncOperationCompletedHandler() + // + // So sleep instead... + var decoder = decoder_task.GetResults(); + var software_bitmap_task = decoder.GetSoftwareBitmapAsync(); + System.Threading.Thread.Sleep(1000); + // software_bitmap_task.AsTask().Wait(); + // + // Unable to call AsTask on IAsyncOperation... + // System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.' + // This exception was originally thrown at this call stack: + // System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType) + // System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[]) + // System.RuntimeType.MakeGenericType(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[]) + // System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[]) + // ABI.Windows.Foundation.AsyncOperationCompletedHandler.AsyncOperationCompletedHandler() + // + // So sleep instead... + using (var software_bitmap = software_bitmap_task.GetResults()) + { + Console.WriteLine("Create VideoFrame."); + var frame = Windows.Media.VideoFrame.CreateWithSoftwareBitmap(software_bitmap); + + Console.WriteLine("Create LearningModelSession."); + using (var session = new LearningModelSession(model)) + { + Console.WriteLine("Create LearningModelBinding."); + var binding = new LearningModelBinding(session); + Console.WriteLine("Bind data_0."); + binding.Bind("data_0", frame); + Console.WriteLine("Evaluate."); + var results = session.Evaluate(binding, ""); + } + Console.WriteLine("Success!\n"); + } + } + } + } + } +} diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config new file mode 100644 index 0000000000..45703bd08c --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config.pp new file mode 100644 index 0000000000..cacc1fee8c --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/packages.config.pp @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore b/csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore new file mode 100644 index 0000000000..b05d286e48 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore @@ -0,0 +1,4 @@ +# build, distribute, and bins (+ python proto bindings) +Debug +x64 +packages \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props new file mode 100644 index 0000000000..e866768105 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props @@ -0,0 +1,6 @@ + + + + 1.3.0-dev-20200528-0441-83196680f + + diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props.pp new file mode 100644 index 0000000000..0242ca34c4 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.props.pp @@ -0,0 +1,6 @@ + + + + [PackageVersion] + + diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.vcxproj b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.vcxproj new file mode 100644 index 0000000000..62e1a8a9b2 --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests/Microsoft.AI.MachineLearning.Tests.vcxproj @@ -0,0 +1,118 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + true + + + + + + true + + + + + + + + + + Document + true + + + + + Always + true + + + + + Always + true + + + + 16.0 + {3BB97C0D-DEC9-4828-A821-78147AE5A488} + Win32Proj + Microsoft.AI.MachineLearning.Tests + 10.0 + + + + v142 + + + v142 + + + v142 + + + v142 + + + Application + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + + + + + + \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp b/csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp new file mode 100644 index 0000000000..5e1c1e65ba --- /dev/null +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp @@ -0,0 +1,56 @@ +#include +#include "winrt/microsoft.ai.machinelearning.h" +#include "winrt/windows.storage.h" +#include "winrt/windows.foundation.h" +#include "winrt/windows.foundation.collections.h" +#include "winrt/Windows.Graphics.h" +#include "winrt/Windows.Graphics.Imaging.h" +#include "winrt/Windows.Media.h" +#include + +EXTERN_C IMAGE_DOS_HEADER __ImageBase; + +using namespace winrt::Microsoft::AI::MachineLearning; +using namespace winrt::Windows::Storage; +using namespace winrt::Windows::Media; +using namespace winrt::Windows::Graphics::Imaging; + +std::wstring GetModulePath() { + std::wstring val; + wchar_t modulePath[MAX_PATH] = {0}; + GetModuleFileNameW((HINSTANCE)&__ImageBase, modulePath, _countof(modulePath)); + wchar_t drive[_MAX_DRIVE]; + wchar_t dir[_MAX_DIR]; + wchar_t filename[_MAX_FNAME]; + wchar_t ext[_MAX_EXT]; + _wsplitpath_s(modulePath, drive, _MAX_DRIVE, dir, _MAX_DIR, filename, _MAX_FNAME, ext, _MAX_EXT); + + val = drive; + val += dir; + + return val; +} + +int main() { + printf("Load squeezenet.onnx.\n"); + auto model = LearningModel::LoadFromFilePath(L"squeezenet.onnx"); + printf("Load kitten_224.png as StorageFile.\n"); + auto name = GetModulePath() + L"kitten_224.png"; + auto image = StorageFile::GetFileFromPathAsync(name).get(); + printf("Load StorageFile into Stream.\n"); + auto stream = image.OpenAsync(FileAccessMode::Read).get(); + printf("Create SoftwareBitmap from decoded Stream.\n"); + auto softwareBitmap = BitmapDecoder::CreateAsync(stream).get().GetSoftwareBitmapAsync().get(); + printf("Create VideoFrame.\n"); + auto frame = VideoFrame::CreateWithSoftwareBitmap(softwareBitmap); + printf("Create LearningModelSession.\n"); + auto session = LearningModelSession(model); + printf("Create LearningModelBinding.\n"); + auto binding = LearningModelBinding(session); + printf("Bind data_0.\n"); + binding.Bind(L"data_0", frame); + printf("Evaluate.\n"); + auto results = session.Evaluate(binding, L""); + printf("Success!\n"); + return 0; +} \ No newline at end of file diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml index 1597b0b7a5..aa3c088091 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml @@ -228,6 +228,126 @@ jobs: PlatformsSupported: 'win-x64,win-x86,win-arm64,win-arm' VerifyNugetSigning: 'true' + - task: BatchScript@1 + displayName: 'Setup VS2019 env vars' + inputs: + filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat' + arguments: 'amd64' + modifyEnvironment: true + + - task: NuGetToolInstaller@0 + displayName: Use Nuget 4.9 + inputs: + versionSpec: 4.9.4 + + - task: PowerShell@2 + displayName: 'NuGet Tests: Restore Windows.AI.MachineLearning Nuget Package (CppWinRT)' + inputs: + targetType: 'inline' + script: | + Add-Type -AssemblyName "System.IO.Compression.FileSystem" + + $packages = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*) + $merged_nuget_package = $packages[0] + $merged_nuget_package_name = $merged_nuget_package.Name + $matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?.*).nupkg") + $package_version = $matches['version'] + + $src_root_dir = $Env:BUILD_SOURCESDIRECTORY; + $artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY; + $merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged') + $src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests') + $packages_dir = [System.IO.Path]::Combine($src_dir, 'packages') + $csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.vcxproj') + + $input_props = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.props.pp') + $output_props = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.props') + $input_props_content = Get-Content -Path $input_props + $output_props_content = $input_props_content -replace '\[PackageVersion\]', $package_version + Set-Content -Path $output_props -Value $output_props_content + + nuget restore -PackagesDirectory $packages_dir -Source https://api.nuget.org/v3/index.json -Source $merged_nuget_path $csproj + + $project_assets_json = [System.IO.Path]::Combine($src_dir, 'obj', 'project.assets.json') + Remove-Item -Force $project_assets_json + workingDirectory: $(Build.ArtifactStagingDirectory)\merged + + - task: PowerShell@2 + displayName: 'NuGet Tests: Restore Windows.AI.MachineLearning Nuget Package (C#)' + inputs: + targetType: 'inline' + script: | + Add-Type -AssemblyName "System.IO.Compression.FileSystem" + + $packages = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*) + $merged_nuget_package = $packages[0] + $merged_nuget_package_name = $merged_nuget_package.Name + $matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?.*).nupkg") + $package_version = $matches['version'] + + $src_root_dir = $Env:BUILD_SOURCESDIRECTORY; + $artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY; + $merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged') + $src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.CSharp') + $packages_dir = [System.IO.Path]::Combine($src_dir, 'packages') + + $input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp') + $csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.CSharp.csproj') + $input_csproj_content = Get-Content -Path $input_csproj + $csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version + Set-Content -Path $csproj -Value $csproj_content + + $input_config = [System.IO.Path]::Combine($src_dir, 'packages.config.pp') + $output_config = [System.IO.Path]::Combine($src_dir, 'packages.config') + $input_config_content = Get-Content -Path $input_config + $output_config_content = $input_config_content -replace '\[PackageVersion\]', $package_version + Set-Content -Path $output_config -Value $output_config_content + + nuget restore -PackagesDirectory $packages_dir -Source https://api.nuget.org/v3/index.json -Source $merged_nuget_path $csproj + workingDirectory: $(Build.ArtifactStagingDirectory)\merged + + - task: PowerShell@2 + displayName: 'NuGet Tests: Build Tests (CppWinRT)' + inputs: + targetType: 'inline' + script: | + msbuild /p:Platform=x86 Microsoft.AI.MachineLearning.Tests.vcxproj + msbuild /p:Platform=x64 Microsoft.AI.MachineLearning.Tests.vcxproj + workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests + + - task: PowerShell@2 + displayName: 'NuGet Tests: Build Tests (C#)' + inputs: + targetType: 'inline' + script: | + msbuild Microsoft.AI.MachineLearning.Tests.CSharp.csproj /p:Platform=AnyCpu + msbuild Microsoft.AI.MachineLearning.Tests.CSharp.csproj /p:Platform=x64 + workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.CSharp + + - task: PowerShell@2 + displayName: 'NuGet Tests: Run Tests' + continueOnError: true + inputs: + targetType: 'inline' + script: | + Write-Host "Run Microsoft.AI.MachineLearning CppWinRT Tests (x86)" + pushd .\Microsoft.AI.MachineLearning.Tests\Debug + .\Microsoft.AI.MachineLearning.Tests.exe + popd + Write-Host "Run Microsoft.AI.MachineLearning CppWinRT Tests (x64)" + pushd .\Microsoft.AI.MachineLearning.Tests\x64\Debug + .\Microsoft.AI.MachineLearning.Tests.exe + popd + Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (AnyCpu)" + pushd .\Microsoft.AI.MachineLearning.Tests.CSharp\bin\Debug + .\Microsoft.AI.MachineLearning.Tests.CSharp.exe + popd + Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (x64)" + pushd .\Microsoft.AI.MachineLearning.Tests.CSharp\bin\x64\Debug + .\Microsoft.AI.MachineLearning.Tests.CSharp.exe + popd + Write-Host "Done!" + workingDirectory: $(Build.SourcesDirectory)\csharp\test - task: PublishPipelineArtifact@0 displayName: 'Publish Pipeline NuGet Artifact' diff --git a/winml/lib/Api/LearningModelBinding.cpp b/winml/lib/Api/LearningModelBinding.cpp index 55007b7297..48071b09c7 100644 --- a/winml/lib/Api/LearningModelBinding.cpp +++ b/winml/lib/Api/LearningModelBinding.cpp @@ -187,7 +187,6 @@ void LearningModelBinding::Clear() try { auto device = m_session.Device().as(); CWinMLAutoLock lock(!device->IsCpuDevice() ? session->GetDMLEPLock() : nullptr); - m_session.as()->CheckClosed(); inputs_.clear(); input_names_.clear(); outputs_.clear();