mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
### Description This PR enables building nuget packages locally for on device training using --build_nuget arg. This PR also enables the C# bindings by default in the managed package. If a user triggers any training apis when the native binary is not built for training, an exception with message "Training is disabled in the current build. Please build ONNXRuntime from source with the build flags enable_training and enable_training_on_device. " is thrown. Build command for creating nuget packes for on device training: build.bat --enable_training --enable_training_on_device --build_nuget 2 Nuget packages are built 1. Microsoft.ML.OnnxRuntime.Managed 2. Microsoft.ML.OnnxRuntime.Training OR Microsoft.ML.OnnxRuntime.Training.Gpu ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
121 lines
6.1 KiB
XML
121 lines
6.1 KiB
XML
<Project Sdk="Microsoft.NET.Sdk">
|
|
|
|
<PropertyGroup>
|
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
<IsPackable>false</IsPackable>
|
|
<OnnxRuntimeCsharpRoot>$(ProjectDir)..\..</OnnxRuntimeCsharpRoot>
|
|
<Platforms>AnyCPU;x86</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>$(OnnxSourceDirectory)\onnx</ProtoSrc>
|
|
<!-- following attributes were necessary for the migrated Tensor tests -->
|
|
<LangVersion>7.2</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 -->
|
|
|
|
<!-- Training build property.
|
|
Should be set to true when training is enabled in onnxruntime native binary -->
|
|
<TrainingEnabledNativeBuild Condition="'$(TrainingEnabledNativeBuild)' == ''">false</TrainingEnabledNativeBuild>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(TrainingEnabledNativeBuild)'=='true'">
|
|
<ExtraDefineConstants>$(ExtraDefineConstants);__TRAINING_ENABLED_NATIVE_BUILD__</ExtraDefineConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<DefineConstants>__NET_CORE_APP__;$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsLinuxBuild)'=='true'">
|
|
<!--internal build related properties for Linux -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Linux</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsWindowsBuild)'=='true'">
|
|
<!--internal build related properties for Windows -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Windows</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsMacOSBuild)'=='true'">
|
|
<!--internal build related properties for OSX -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\MacOS</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0" />
|
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
|
<PackageReference Include="xunit" Version="2.4.1" />
|
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<None Include="$(NativeBuildOutputDir)\*.dll;$(NativeBuildOutputDir)\*.pdb;$(NativeBuildOutputDir)\*.dylib;$(NativeBuildOutputDir)\libcustom*.so;$(NativeBuildOutputDir)\libcustom*.dylib">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
|
|
<None Include="$(OnnxRuntimeCSharpRoot)\testdata\*">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
<None Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\overridable_initializer.onnx">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
<None Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\capi_symbolic_dims.onnx">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
<None Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\custom_op_library\custom_op_test.onnx">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
<BuildEnvVars Include="OnnxRuntimeBuildDirectory=$(OnnxRuntimeBuildDirectory)" />
|
|
</ItemGroup>
|
|
|
|
<Target Name="DefineBuildEnvironmentVariables" BeforeTargets="Build">
|
|
<WriteLinesToFile File="$(OutputPath)\Properties.txt" Lines="@(BuildEnvVars)" Overwrite="true" />
|
|
</Target>
|
|
|
|
<ItemGroup>
|
|
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
</ItemGroup>
|
|
|
|
<!-- NOTE: The xUnit framework doesn't pickup the tests defined within the referenced Microsoft.ML.OnnxRuntime.Tests.Common project -->
|
|
<ItemGroup>
|
|
<Compile Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\InferenceTest.cs">
|
|
<Link>InferenceTest.cs</Link>
|
|
</Compile>
|
|
<Compile Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\OrtIoBindingAllocationTest.cs">
|
|
<Link>OrtIoBindingAllocationTest.cs</Link>
|
|
</Compile>
|
|
<Compile Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\Tensors\TensorTests.cs">
|
|
<Link>TensorTests.cs</Link>
|
|
</Compile>
|
|
<Compile Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\Tensors\ArrayTensorExtensionsTests.cs">
|
|
<Link>ArrayTensorExtensionsTests.cs</Link>
|
|
</Compile>
|
|
<Compile Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\TrainingTest.cs">
|
|
<Link>TrainingTest.cs</Link>
|
|
</Compile>
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<None Include="$(OnnxRuntimeCSharpRoot)\..\onnxruntime\test\testdata\training_api\**\*.*">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
<Visible>false</Visible>
|
|
</None>
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<ProjectReference Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\Microsoft.ML.OnnxRuntime.Tests.Common.csproj" />
|
|
</ItemGroup>
|
|
</Project>
|