System.Numerics.Tensors 9.0.14
About
Provides methods for performing mathematical operations over tensors represented as spans. These methods are accelerated to use SIMD (Single instruction, multiple data) operations supported by the CPU where available.
Key Features
- Numerical operations on tensors represented as
ReadOnlySpan<float> - Element-wise arithmetic: Add, Subtract, Multiply, Divide, Exp, Log, Cosh, Tanh, etc.
- Tensor arithmetic: CosineSimilarity, Distance, Dot, Normalize, Softmax, Sigmoid, etc.
How to Use
using System.Numerics.Tensors;
var movies = new[] {
new { Title="The Lion King", Embedding= new [] { 0.10022575f, -0.23998135f } },
new { Title="Inception", Embedding= new [] { 0.10327095f, 0.2563685f } },
new { Title="Toy Story", Embedding= new [] { 0.095857024f, -0.201278f } },
new { Title="Pulp Function", Embedding= new [] { 0.106827796f, 0.21676421f } },
new { Title="Shrek", Embedding= new [] { 0.09568083f, -0.21177962f } }
};
var queryEmbedding = new[] { 0.12217915f, -0.034832448f };
var top3MoviesTensorPrimitives =
movies
.Select(movie =>
(
movie.Title,
Similarity: TensorPrimitives.CosineSimilarity(queryEmbedding, movie.Embedding)
))
.OrderByDescending(movies => movies.Similarity)
.Take(3);
foreach (var movie in top3MoviesTensorPrimitives)
{
Console.WriteLine(movie);
}
Main Types
The main types provided by this library are:
System.Numerics.Tensors.TensorPrimitives
Additional Documentation
Feedback & Contributing
System.Numerics.Tensors is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on System.Numerics.Tensors.
| Packages | Downloads |
|---|---|
|
Microsoft.WindowsAppSDK.ML
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. This package contains the Windows Machine Learning APIs.
|
5 |
|
Microsoft.WindowsAppSDK.ML
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. This package contains the Windows Machine Learning APIs.
|
4 |
|
Microsoft.WindowsAppSDK.ML
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. This package contains the Windows Machine Learning APIs.
|
3 |
|
Microsoft.WindowsAppSDK.ML
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. This package contains the Windows Machine Learning APIs.
|
2 |
|
Microsoft.WindowsAppSDK.ML
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. This package contains the Windows Machine Learning APIs.
|
1 |
|
Microsoft.Windows.AI.MachineLearning
Microsoft Windows AI Machine Learning APIs. This package provides the Windows ML runtime, ONNX Runtime integration, and DirectML support for Windows desktop applications. Minimum OS: Windows 10 19H1 (Build 18362) or later. For support down to 17763, install Microsoft.WindowsAppSDK.ML.
|
1 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Bcl.Numerics (>= 9.0.14)
- System.Memory (>= 4.5.5)
.NET 8.0
- No dependencies.
.NET 9.0
- No dependencies.
.NET Standard 2.0
- Microsoft.Bcl.Numerics (>= 9.0.14)
- System.Memory (>= 4.5.5)