-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Need to refactor CpuMath to enable using C# intrinsics APIs on .NET Core #534
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
Comments
eerhardt
added a commit
to eerhardt/machinelearning
that referenced
this issue
Jul 17, 2018
Need to multi-target CpuMath for netstandard and netcoreapp3.0. Also, since we are going to move CpuMath into its own NuGet package, remove the dependency from CpuMath to the ML.Core project. Add a build parameter to enable building against .NET Core 3.0's Runtime Intrinsics APIs. Fix dotnet#534
eerhardt
added a commit
that referenced
this issue
Jul 19, 2018
* Allow CpuMath to reference C# Hardware Intrinsics APIs. Need to multi-target CpuMath for netstandard and netcoreapp3.0. Also, since we are going to move CpuMath into its own NuGet package, remove the dependency from CpuMath to the ML.Core project. Add a build parameter to enable building against .NET Core 3.0's Runtime Intrinsics APIs. Fix #534 * Respond to PR feedback.
eerhardt
added a commit
to eerhardt/machinelearning
that referenced
this issue
Jul 27, 2018
* Allow CpuMath to reference C# Hardware Intrinsics APIs. Need to multi-target CpuMath for netstandard and netcoreapp3.0. Also, since we are going to move CpuMath into its own NuGet package, remove the dependency from CpuMath to the ML.Core project. Add a build parameter to enable building against .NET Core 3.0's Runtime Intrinsics APIs. Fix dotnet#534 * Respond to PR feedback.
codemzs
pushed a commit
to codemzs/machinelearning
that referenced
this issue
Aug 1, 2018
* Allow CpuMath to reference C# Hardware Intrinsics APIs. Need to multi-target CpuMath for netstandard and netcoreapp3.0. Also, since we are going to move CpuMath into its own NuGet package, remove the dependency from CpuMath to the ML.Core project. Add a build parameter to enable building against .NET Core 3.0's Runtime Intrinsics APIs. Fix dotnet#534 * Respond to PR feedback.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
.NET Core 2.1 introduced hardware intrinsics APIs that allow C# code to take full advantage of the CPU. For example, you can now write algorithms using SSE or AVX instructions purely from C# code.
The CpuMathNative assembly exists solely so ML.NET can take advantage of SSE and AVX instructions in its algorithms. When running on .NET Core 2.1+, we can remove our dependency on this native assembly, and instead port the C++ SIMD code to using the new C# intrinsics APIs.
However, to do this (and still support the full .NET Framework), we need to do some refactoring to our assemblies and NuGet packages.
The first thing we need to do is allow
Microsoft.ML.CpuMath
to be multi-targeted fornetstandard2.0;netcoreapp2.1
. This will allow us to compile against the netcoreapp2.1 specific SSE APIs.However, doing that affects our
Microsoft.ML
nuget package. This is because when you make a nuget package, you put your assemblies into TFM specific folderslib\netstandard2.0
,lib\netcoreapp2.1
, etc. And the way asset picking works is that once it finds assets for a specific TFM, it stops looking. (The reasoning is typically there is a single assembly per nuget package.) So if we have a single assembly, CpuMath, that needs to go into bothlib\netstandard2.0
andlib\netcoreapp2.1
, we have a problem. It means ALL our assemblies need to go into BOTH folders, which is unnecessary duplication.To solve this duplication, I propose to split CpuMath into its own nuget package. So we will have this structure:
Microsoft.ML.CpuMath
Microsoft.ML
Microsoft.ML.CpuMath
.In order to do this correctly, we need to remove the assembly reference from
Microsoft.ML.CpuMath.dll
onMicrosoft.ML.Core.dll
. This is because the nuget dependency goes the other way. The only reasonMicrosoft.ML.CpuMath.dll
depends onMicrosoft.ML.Core.dll
is so it can use theContracts
class. We can break this dependency by using thePRIVATE_CONTRACTS
define constant, and source linking theContracts.cs
file into CpuMath./cc @TomFinley @ericstj @briancylui @tannergooding
The text was updated successfully, but these errors were encountered: