onnxruntime/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Microsoft.ML.OnnxRuntime.Tests.Common.csproj
Dmitri Smirnov 1e18efade5
[C#] Add ML Sequences and Maps Create and Process APIs (#16648)
### Description
1) Added Sequence And Maps convenience APIs to create input Sequences
and Maps
and also visit the outputs.

2) Address OrtValue design issue when the values are created on top of
the
managed memory and the ortValues are used for sequence and maps
creation.
We should retain the original managed instances that keep the memory
pinned.
We opt to keep track of those and dispose of them within an instance of
OrtValue
that represents a Map or a Sequence.

3) Set `LangVersion` to default per [MS Versioning
Docs.](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version)

### Motivation and Context
1) When writing code examples, use of Map and Sequences API proved to be
cumbersome.
2) It is a BUG, that we should address, as the managed memory can move
by the GC and lead to
intermittent crashes.
3) Make use of the most feature of the C#.
2023-07-21 12:58:29 +08:00

164 lines
8 KiB
XML

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- netstandard2.0 is required by xamarin and used by most platforms.
net6.0 is required for linux. -->
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<OnnxRuntimeCsharpRoot>$(ProjectDir)..\..</OnnxRuntimeCsharpRoot>
<Platforms>AnyCPU</Platforms>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IsLinuxBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinuxBuild>
<IsWindowsBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindowsBuild>
<IsMacOSBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsMacOSBuild>
<ProtoSrc>$(OnnxRuntimeCsharpRoot)\..\cmake\external\onnx</ProtoSrc>
<!-- following attributes were necessary for the migrated Tensor tests -->
<LangVersion>default</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly> <!-- need signing for friend access to the internals of the Tensors assembly -->
<AssemblyOriginatorKeyFile>..\..\OnnxRuntime.snk</AssemblyOriginatorKeyFile>
<Configurations>Debug;Release;RelWithDebInfo</Configurations>
<!-- end -->
<RootNamespace>Microsoft.ML.OnnxRuntime.Tests</RootNamespace>
<AssemblyName>Microsoft.ML.OnnxRuntime.Tests.Common</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinuxBuild)'=='true'">
<!--internal build related properties for Linux -->
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Linux</OnnxRuntimeBuildDirectory>
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
<ProtocDirectory Condition="'$(ProtocDirectory)'==''">$(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake</ProtocDirectory>
<ProtocExe>$(ProtocDirectory)\protoc</ProtocExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindowsBuild)'=='true'">
<!--internal build related properties for Windows -->
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Windows</OnnxRuntimeBuildDirectory>
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</NativeBuildOutputDir>
<ProtocDirectory Condition="'$(ProtocDirectory)'==''">$(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)</ProtocDirectory>
<ProtocExe>$(ProtocDirectory)\protoc.exe</ProtocExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsMacOSBuild)'=='true'">
<!--internal build related properties for OSX -->
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\MacOS</OnnxRuntimeBuildDirectory>
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
<ProtocDirectory Condition="'$(ProtocDirectory)'==''">$(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake</ProtocDirectory>
<ProtocExe>$(ProtocDirectory)\protoc</ProtocExe>
</PropertyGroup>
<ItemGroup>
<Compile Remove="InferenceTest.cs" />
<Compile Remove="OrtIoBindingAllocationTest.cs" />
<Compile Remove="OrtEnvTests.cs" />
<Compile Remove="OrtValueTests.cs" />
<Compile Remove="OrtFloat16Tests.cs" />
<Compile Remove="Tensors\TensorTests.cs" />
<Compile Remove="TrainingTest.cs" />
</ItemGroup>
<ItemGroup>
<Compile Update="Tensors\TensorArithmetic.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Tensors\TensorArithmetic.tt</DependentUpon>
</Compile>
<Compile Update="Tensors\TensorOperations.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Tensors\TensorOperations.tt</DependentUpon>
</Compile>
<Compile Update="Tensors\TensorArithmetic.cs">
<DependentUpon>TensorArithmetic.tt</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Compile Update="Tensors\TensorOperations.cs">
<DependentUpon>TensorOperations.tt</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
</ItemGroup>
<ItemGroup>
<!-- include common files for visibility, however they're compiled directly by the target specific test projects -->
<None Include="InferenceTest.cs" />
<None Include="OnnxData.cs" />
<None Include="OrtIoBindingAllocationTest.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
<None Include="OrtValueTests.cs" />
<None Include="OrtFloat16Tests.cs" />
<None Include="Tensors\TensorTests.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
<None Include="Tensors\ArrayTensorExtensionTests.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
<None Include="TrainingTest.cs" />
</ItemGroup>
<ItemGroup>
<None Update="Tensors\TensorArithmetic.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>TensorArithmetic.cs</LastGenOutput>
</None>
<None Update="Tensors\TensorOperations.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>TensorOperations.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Condition="'$(IsWindowsBuild)'=='true'" Include="$(NativeBuildOutputDir)\onnxruntime.dll;$(NativeBuildOutputDir)\onnxruntime.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<None Condition="'$(IsLinuxBuild)'=='true'" Include="$(NativeBuildOutputDir)\libonnxruntime.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<None Condition="'$(IsMacOSBuild)'=='true'" Include="$(NativeBuildOutputDir)\libonnxruntime.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Google.Protobuf" Version="3.16.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(OnnxRuntimeCsharpRoot)\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj" />
</ItemGroup>
<!-- generate OnnxMl.cs from ONNX protobuf definition -->
<Target Name="ProtoGen" BeforeTargets="BeforeBuild" Condition="Exists('$(ProtocExe)')">
<Exec Command="$(ProtocExe) -I=$(ProtoSrc) --csharp_out=. $(ProtoSrc)\onnx\onnx-ml.proto3" ContinueOnError="false"></Exec>
</Target>
<Target Name="ProtoDataGen" BeforeTargets="BeforeBuild" Condition="Exists('$(ProtocExe)')">
<Exec Command="$(ProtocExe) -I=$(ProtoSrc) --csharp_out=. $(ProtoSrc)\onnx\onnx-data.proto3" ContinueOnError="false"></Exec>
</Target>
<ItemGroup>
<BuildEnvVars Include="OnnxRuntimeBuildDirectory=$(OnnxRuntimeBuildDirectory)" />
</ItemGroup>
<Target Name="DefineBuildEnvironmentVariables" BeforeTargets="Build">
<WriteLinesToFile File="$(OutputPath)\Properties.txt" Lines="@(BuildEnvVars)" Overwrite="true" />
</Target>
<ItemGroup>
<EmbeddedResource Include="..\..\testdata\*">
<Link>TestData\%(Filename)%(Extension)</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\overridable_initializer.onnx">
<Link>TestData\overridable_initializer.onnx</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\capi_symbolic_dims.onnx">
<Link>TestData\capi_symbolic_dims.onnx</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>