MKL.NET
1.6.0
dotnet add package MKL.NET --version 1.6.0
NuGet\Install-Package MKL.NET -Version 1.6.0
<PackageReference Include="MKL.NET" Version="1.6.0" />
paket add MKL.NET --version 1.6.0
#r "nuget: MKL.NET, 1.6.0"
// Install MKL.NET as a Cake Addin #addin nuget:?package=MKL.NET&version=1.6.0 // Install MKL.NET as a Cake Tool #tool nuget:?package=MKL.NET&version=1.6.0
MKL.NET
A simple cross platform .NET API for Intel MKL.
Exposing functions from MKL keeping the syntax as close to the c developer reference as possible.
Reference the MKL.NET package and required runtime packages and use the static MKL functions. The correct native libraries will be included and loaded at runtime.
If you use your own copy of MKL native libraries please make sure that mkl_rt.dll
/libmkl_rt.so
/libmkl_rt.dylib
is on the path. Newer MKL builds include a version number in the library name, so you will have to create a link or rename it. The names are already adjusted in the MKL.NET packages which work out of the box.
MKL.NET | |
---|---|
runtimes: | |
MKL.NET.win-x64 | |
MKL.NET.win-x86 | |
MKL.NET.linux-x64 | |
MKL.NET.linux-x86 | |
MKL.NET.osx-x64 | |
libraries: | |
MKL.NET.Matrix | |
MKL.NET.Optimization | |
MKL.NET.Statistics |
Rationale
- Use freely available Intel MKL packages repackaged to work for each runtime.
- The MKL.NET API is just a thin .NET wrapper around the native API keeping the syntax as close as possible.
- The project is well defined, with an open design, and no business logic and could benefit from external input.
- Cross platform testing is easy and free using Github actions.
- MKL.NET native packages can just be referenced for needed runtimes at library or application level.
MKL.NET.Matrix
- Performance and memory optimised matrix algebra library.
- Matrix expressions are optimised to perform intermediate calculations inplace and reuse memory.
- Operations such as scale, transpose, +, * are combined into single MKL calls.
- Intermediate matrices are disposed (or reused) automatically.
- ArrayPool underlying memory model using IDisposable and Finalizers.
- Uses the Pinned Object Heap for net6.0.
- All these combined result in it being much faster than other matrix libraries.
The following example only results in one new matrix r (using ArrayPool) without mutating inputs.
public static matrix Example(matrix ma, matrix mb, vector va, vector vb)
{
using matrix r = 0.5 * Matrix.Abs(1.0 - ma) * mb.T + Math.PI * va.T * Vector.Sin(vb);
...
}
Example statistics matrix function:
public static (vector, matrix) MeanAndCovariance(matrix samples, vector weights)
{
if (samples.Rows != weights.Length) ThrowHelper.ThrowIncorrectDimensionsForOperation();
var mean = new vector(samples.Cols);
var cov = new matrix(samples.Cols, samples.Cols);
var task = Vsl.SSNewTask(samples.Cols, samples.Rows, VslStorage.ROWS, samples.Array, weights.Array);
ThrowHelper.Check(Vsl.SSEditCovCor(task, mean.Array, cov.Array, VslFormat.FULL, null, VslFormat.FULL));
ThrowHelper.Check(Vsl.SSCompute(task, VslEstimate.COV, VslMethod.FAST));
ThrowHelper.Check(Vsl.SSDeleteTask(task));
return (mean, cov);
}
Note: arrays need to be pinned across all MKL function calls when there are multiple as above as MKL stores native pointers and the arrays could be moved between calls. MKL.NET handles pinning automatically, unpinning when the task is deleted. This is a common seen bug when using MKL directly from .NET which causes occasional crashes.
MKL.NET.Optimization
Simple and high performance optimization and root finding library loosely based on the scipy.optimize API.
The aim is to include the latest algorithms such as Toms748, robustly tested with CsCheck. Full use of MKL.NET will be made to improve performance. Algorithms will be performance tested and default to the best for given inputs.
- Root - root finding algorithms. Default algorithm has 20% fewer function calls than Brent, Toms748, Newton and Halley. Further details here.
- Calculus - derivative and integral numeric calculations and check to any precision using Richardson extrapolation.
- Minimum - minimum finding algorithms in one dimension. Default algorithm has 50% fewer function calls than Brent.
- Minimum - in N dimensions. Intuative tolerance parameters. Optimised no array allocation in main loop using in place symmetric MKL rank-k, rank-2k functions.
Should scale well with the number of dimensions. ~ 50-70% fewer function calls than other BFGS algorithms. - CurveFit and non-linear LeastSquares - helper functions based on Minimum.
- Minimum_Global - global minimum algorithm in N dimensions returning a sequence of parallel grid BFGS searches ever reducing the spacing between prior searches. Further details here.
MKL.NET.Statistics
Simple and high performance statistics functions.
- Summary - Sum, Mean, Median, MAD, Raw/Central/Standard Moments, Quartiles, Quantiles, Covariance, Correlation. All can be weighted.
- Estimator - Running high performance, low memory estimators for Quantile, Quartiles, Quantiles, Histogram, Central/Standard Moments. Further details here.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory (>= 4.5.5)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on MKL.NET:
Package | Downloads |
---|---|
MKL.NET.Matrix
Performance and memory optimised matrix algebra library based on cross platform MKL.NET. - Matrix expressions are optimised to perform intermediate calculations inplace and reuse memory. - Operations such as scale, transpose, +, * are combined into single MKL calls. - Intermediate matrices are disposed (or reused) automatically. - ArrayPool underlying memory model using IDisposable and Finalizers. - Uses the Pinned Object Heap for net6.0. |
|
ParallelReverseAutoDiff
A library for parallelized reverse mode automatic differentiation in C# for custom neural network development. |
|
MKL.NET.Optimization
Optimization and root finding based on cross platform MKL.NET. |
|
ParallelReverseAutoDiffLite
A lightweight library for parallelized reverse mode automatic differentiation in C# for custom neural network development using single-precision. |
|
RyzhkovCNN.Model
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on MKL.NET:
Repository | Stars |
---|---|
jdermody/brightwire
Bright Wire is an open source machine learning library for .NET with GPU support (via CUDA)
|
Version | Downloads | Last updated |
---|---|---|
1.6.0 | 449 | 9/22/2024 |
1.5.0 | 3,024 | 8/21/2023 |
1.4.1 | 5,301 | 4/9/2023 |
1.4.0 | 646 | 2/8/2023 |
1.3.2 | 26,991 | 9/28/2021 |
1.3.1 | 410 | 9/27/2021 |
1.3.0 | 1,277 | 9/26/2021 |
1.2.3 | 1,386 | 8/26/2021 |
1.2.2 | 390 | 8/25/2021 |
1.2.1 | 2,313 | 6/23/2021 |
1.2.0 | 378 | 6/20/2021 |
1.2.0-rc1 | 312 | 6/18/2021 |
1.1.3 | 2,081 | 6/9/2021 |
1.1.2 | 432 | 6/8/2021 |
1.1.1 | 380 | 6/8/2021 |
1.1.0 | 1,389 | 1/30/2021 |
1.0.0 | 2,106 | 1/16/2021 |
0.9.0 | 2,180 | 10/13/2020 |
0.8.0 | 468 | 9/30/2020 |
0.7.0 | 472 | 9/22/2020 |
0.6.0 | 543 | 9/17/2020 |
0.5.0 | 566 | 9/13/2020 |
0.4.0 | 539 | 9/9/2020 |
0.3.0 | 839 | 9/7/2020 |
0.2.3-preview | 399 | 9/6/2020 |
0.2.2-preview | 402 | 9/6/2020 |
0.2.1-preview | 407 | 9/6/2020 |
0.2.0-preview | 414 | 9/6/2020 |
0.1.0-preview | 334 | 9/2/2020 |
Enable 2d FFT. Thanks minghao-guo.