mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-28 22:56:32 +00:00
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 <sheilk@microsoft.com>
This commit is contained in:
parent
612f52c975
commit
fdb4a3a2e8
13 changed files with 640 additions and 1 deletions
4
csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore
vendored
Normal file
4
csharp/test/Microsoft.AI.MachineLearning.Tests.CSharp/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# build, distribute, and bins (+ python proto bindings)
|
||||
Debug
|
||||
x64
|
||||
packages
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Microsoft.AI.MachineLearning.Tests.CSharp</RootNamespace>
|
||||
<AssemblyName>Microsoft.AI.MachineLearning.Tests.CSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AI.MachineLearning.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Windows.SDK.NET, Version=10.0.18362.3, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="winrt.runtime, Version=0.1.0.1677, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\lib\netstandard2.0\winrt.runtime.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="main.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\testdata\squeezenet.onnx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>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}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets'))" />
|
||||
</Target>
|
||||
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" />
|
||||
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Microsoft.AI.MachineLearning.Tests.CSharp</RootNamespace>
|
||||
<AssemblyName>Microsoft.AI.MachineLearning.Tests.CSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AI.MachineLearning.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AI.MachineLearning.[PackageVersion]\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Windows.SDK.NET, Version=10.0.18362.3, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="winrt.runtime, Version=0.1.0.1677, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\lib\netstandard2.0\winrt.runtime.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="main.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\testdata\squeezenet.onnx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>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}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets'))" />
|
||||
</Target>
|
||||
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" />
|
||||
<Import Project="packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" />
|
||||
</Project>
|
||||
|
|
@ -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<IRandomAccessStreamWithContentType>...
|
||||
// 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<TResult>.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<SoftwareBitmap>...
|
||||
// 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<TResult>.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<SoftwareBitmap>...
|
||||
// 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<TResult>.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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AI.MachineLearning" version="1.3.1-dev-20200626-0616-f44313c3d" targetFramework="net472" />
|
||||
<package id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200512.7" targetFramework="net472" />
|
||||
<package id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" targetFramework="net472" />
|
||||
</packages>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AI.MachineLearning" version="[PackageVersion]" targetFramework="net472" />
|
||||
<package id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200512.7" targetFramework="net472" />
|
||||
<package id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" targetFramework="net472" />
|
||||
</packages>
|
||||
4
csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore
vendored
Normal file
4
csharp/test/Microsoft.AI.MachineLearning.Tests/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# build, distribute, and bins (+ python proto bindings)
|
||||
Debug
|
||||
x64
|
||||
packages
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<WindowsAIVersion>1.3.0-dev-20200528-0441-83196680f</WindowsAIVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<WindowsAIVersion>[PackageVersion]</WindowsAIVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<EnableNuGetPackageRestore>true</EnableNuGetPackageRestore>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="Microsoft.AI.MachineLearning.Tests.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<CppWinRTPackage>true</CppWinRTPackage>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AI.MachineLearning" Version="$(WindowsAIVersion)" targetframework="native" />
|
||||
<PackageReference Include="Microsoft.Windows.CppWinRT" Version="2.0.200615.7" targetframework="native" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<FileType>Document</FileType>
|
||||
<DeploymentContent>true</DeploymentContent>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\testdata\squeezenet.onnx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<Visible>true</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{3BB97C0D-DEC9-4828-A821-78147AE5A488}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Microsoft.AI.MachineLearning.Tests</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
56
csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp
Normal file
56
csharp/test/Microsoft.AI.MachineLearning.Tests/main.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include <stdio.h>
|
||||
#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 <windows.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -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.(?<version>.*).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.(?<version>.*).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'
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@ void LearningModelBinding::Clear() try {
|
|||
auto device = m_session.Device().as<winmlp::LearningModelDevice>();
|
||||
CWinMLAutoLock lock(!device->IsCpuDevice() ? session->GetDMLEPLock() : nullptr);
|
||||
|
||||
m_session.as<winmlp::LearningModelSession>()->CheckClosed();
|
||||
inputs_.clear();
|
||||
input_names_.clear();
|
||||
outputs_.clear();
|
||||
|
|
|
|||
Loading…
Reference in a new issue