-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Allow CpuMath to reference C# Hardware Intrinsics APIs. #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework Condition="'$(UseIntrinsics)' != 'true'">netstandard2.0</TargetFramework> | ||
| <TargetFrameworks Condition="'$(UseIntrinsics)' == 'true'">netstandard2.0;netcoreapp3.0</TargetFrameworks> | ||
| <PackageDescription>Microsoft.ML.CpuMath contains optimized math routines for ML.NET.</PackageDescription> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'"> | ||
| <!-- This is only needed until https://github.com/dotnet/corefx/issues/31064 is addressed. --> | ||
| <PackageReference Include="System.Runtime.Intrinsics.Experimental" Version="4.6.0-preview1-26708-04" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <Project DefaultTargets="Pack"> | ||
|
|
||
| <Import Project="Microsoft.ML.CpuMath.nupkgproj" /> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netstandard2.0</TargetFramework> | ||
| <IncludeInPackage>Microsoft.ML</IncludeInPackage> | ||
| <Configurations>Debug;Release;Debug-Intrinsics;Release-Intriniscs</Configurations> | ||
| <UseIntrinsics Condition="'$(UseIntrinsics)' == ''">$(Configuration.EndsWith('-Intrinsics'))</UseIntrinsics> | ||
|
|
||
| <TargetFramework Condition="'$(UseIntrinsics)' != 'true'">netstandard2.0</TargetFramework> | ||
| <TargetFrameworks Condition="'$(UseIntrinsics)' == 'true'">netstandard2.0;netcoreapp3.0</TargetFrameworks> | ||
| <IncludeInPackage>Microsoft.ML.CpuMath</IncludeInPackage> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| <DefineConstants>CORECLR</DefineConstants> | ||
| <DefineConstants>$(DefineConstants);CORECLR;PRIVATE_CONTRACTS</DefineConstants> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" /> | ||
| <Compile Include="..\Microsoft.ML.Core\Utilities\Contracts.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'"> | ||
| <!-- This is only needed until https://github.com/dotnet/corefx/issues/31064 is addressed. --> | ||
| <PackageReference Include="System.Runtime.Intrinsics.Experimental" Version="4.6.0-preview1-26708-04" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,12 @@ | |
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" /> | ||
|
|
||
| <!-- Target that builds all the native binaries in the Native folder --> | ||
| <Target Name="Build" DependsOnTargets="BuildNativeUnix;BuildNativeWindows;PreparePackageAssets" /> | ||
| <Target Name="Build" DependsOnTargets="BuildNativeUnix;BuildNativeWindows;PreparePackageAssets" /> | ||
|
|
||
| <PropertyGroup> | ||
| <PlaceholderFile>$(PkgDir)_._</PlaceholderFile> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(OS)' != 'Windows_NT'"> | ||
| <GenerateVersionSourceFile>true</GenerateVersionSourceFile> | ||
| <NativeVersionSourceFile>$(BaseIntermediateOutputPath)version.c</NativeVersionSourceFile> | ||
|
|
@@ -68,19 +72,29 @@ | |
| <PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ItemGroup Condition="'$(UseIntrinsics)' != 'true'"> | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)CpuMathNative$(NativeLibExtension)" | ||
| RelativePath="Microsoft.ML\runtimes\$(PackageRid)\native" /> | ||
| RelativePath="Microsoft.ML.CpuMath\runtimes\$(PackageRid)\native" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(UseIntrinsics)' == 'true'"> | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)CpuMathNative$(NativeLibExtension)" | ||
| RelativePath="Microsoft.ML.CpuMath\runtimes\$(PackageRid)\lib\netstandard2.0" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't put native files under lib. .NETCore will not like this. For native libraries that must be constrained by both tfm and RID use nativeassets.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, perfect. I was unaware of this and looked on the docs, but didn't find it. Thanks for the info. I'll make the switch.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I poked the doc issue on it. |
||
| <NativePackageAsset Include="$(PlaceholderFile)" | ||
| RelativePath="Microsoft.ML.CpuMath\runtimes\$(PackageRid)\lib\netcoreapp3.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)FastTreeNative$(NativeLibExtension)" | ||
| RelativePath="Microsoft.ML\runtimes\$(PackageRid)\native" /> | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)LdaNative$(NativeLibExtension)" | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)LdaNative$(NativeLibExtension)" | ||
| RelativePath="Microsoft.ML\runtimes\$(PackageRid)\native" /> | ||
| <NativePackageAsset Include="$(NativeAssetsBuiltPath)\$(NativeLibPrefix)FactorizationMachineNative$(NativeLibExtension)" | ||
| RelativePath="Microsoft.ML\runtimes\$(PackageRid)\native" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <NativePackageAsset Condition="'$(OS)' == 'Windows_NT' OR '$(StripNativeSymbols)' == 'True'" | ||
| <NativePackageAsset Condition="('$(OS)' == 'Windows_NT' OR '$(StripNativeSymbols)' == 'True') | ||
| AND '%(NativePackageAsset.Identity)' != '$(PlaceholderFile)'" | ||
| Include="@(NativePackageAsset->'%(RootDir)%(Directory)%(Filename)$(NativeLibSymbolExtension)')" /> | ||
| </ItemGroup> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who sets this configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: "Release-Intriniscs" could probably be "Release-Intrinsics".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@briancylui - nice catch.
@ericstj - the idea is that this build switch is turned off by default. While developing his feature, @briancylui can switch VS to use these 2 new configurations using the configuration manager to build/run tests locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, and you aren't going to turn it on in CI or official build yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, "no" for official build. I don't want to affect the official product until we are ready to affect it (3.0 doesn't even have a preview out yet, so getting it into customers hands isn't a critical concern for me).
We will eventually turn CI on for it, especially as we move closer to wanting to put it in the official product.