System.Numerics.Tensors 9.0.22

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.SemanticKernel.Core
Semantic Kernel core orchestration, runtime and functions. This package is automatically installed by 'Microsoft.SemanticKernel' package with other useful packages. Install this package manually only if you are selecting individual Semantic Kernel components.
25
Microsoft.SemanticKernel.Core
Semantic Kernel core orchestration, runtime and functions. This package is automatically installed by 'Microsoft.SemanticKernel' package with other useful packages. Install this package manually only if you are selecting individual Semantic Kernel components.
27
Microsoft.SemanticKernel.Core
Semantic Kernel core orchestration, runtime and functions. This package is automatically installed by 'Microsoft.SemanticKernel' package with other useful packages. Install this package manually only if you are selecting individual Semantic Kernel components.
28
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
25
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
26
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
27
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
28
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
29
Microsoft.SemanticKernel.Plugins.Memory
Semantic Kernel Memory Plugin
30

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

  • No dependencies.

.NET 9.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
11.0.0-rc.3.26522.148 1 10/27/2026
11.0.0-rc.2.26504.105 2 10/18/2026
11.0.0-rc.1.26425.128 4 09/17/2026
11.0.0-preview.7.26381.103 2 08/23/2026
11.0.0-preview.6.26359.118 5 07/25/2026
11.0.0-preview.5.26302.115 7 06/15/2026
11.0.0-preview.4.26230.115 7 05/24/2026
11.0.0-preview.3.26207.106 6 04/19/2026
11.0.0-preview.2.26159.112 10 03/15/2026
11.0.0-preview.1.26104.118 10 02/11/2026
10.0.14 1 10/27/2026
10.0.13 2 10/18/2026
10.0.12 2 09/17/2026
10.0.11 2 08/23/2026
10.0.10 4 07/21/2026
10.0.9 7 06/14/2026
10.0.8 10 05/22/2026
10.0.7 6 05/07/2026
10.0.6 7 04/19/2026
10.0.5 10 03/15/2026
10.0.4 10 03/14/2026
10.0.3 14 02/11/2026
10.0.2 15 01/16/2026
10.0.1 17 12/10/2025
10.0.0 15 11/13/2025
10.0.0-rc.2.25502.107 16 10/16/2025
10.0.0-rc.1.25451.107 17 09/11/2025
10.0.0-preview.7.25380.108 19 08/14/2025
10.0.0-preview.6.25358.103 19 08/09/2025
10.0.0-preview.5.25277.114 18 06/07/2025
10.0.0-preview.4.25258.110 17 05/14/2025
10.0.0-preview.3.25171.5 18 04/27/2025
10.0.0-preview.2.25163.2 19 04/27/2025
10.0.0-preview.1.25080.5 17 04/27/2025
9.0.22 1 10/27/2026
9.0.21 2 10/18/2026
9.0.20 2 09/17/2026
9.0.19 2 08/23/2026
9.0.18 4 07/21/2026
9.0.17 4 06/15/2026
9.0.16 8 05/22/2026
9.0.15 9 04/19/2026
9.0.14 10 03/14/2026
9.0.13 16 02/11/2026
9.0.12 13 01/16/2026
9.0.11 18 11/13/2025
9.0.10 17 10/16/2025
9.0.9 17 09/11/2025
9.0.8 22 08/11/2025
9.0.7 20 07/30/2025
9.0.6 19 06/27/2025
9.0.5 22 05/14/2025
9.0.4 19 04/27/2025
9.0.3 22 04/27/2025
9.0.2 24 04/27/2025
9.0.1 19 04/27/2025
9.0.0 19 04/27/2025
9.0.0-rc.2.24473.5 16 04/27/2025
9.0.0-rc.1.24431.7 16 04/27/2025
9.0.0-preview.7.24405.7 19 04/27/2025
9.0.0-preview.6.24327.7 20 05/02/2025
9.0.0-preview.5.24306.7 18 04/27/2025
9.0.0-preview.4.24266.19 17 04/27/2025
9.0.0-preview.3.24172.9 17 04/27/2025
9.0.0-preview.2.24128.5 17 04/27/2025
9.0.0-preview.1.24080.9 18 04/27/2025
8.0.0 20 04/08/2025
8.0.0-rc.2.23479.6 18 04/27/2025
8.0.0-rc.1.23419.4 16 04/27/2025
8.0.0-preview.7.23375.6 19 04/27/2025
8.0.0-preview.6.23329.7 17 04/27/2025
8.0.0-preview.5.23280.8 13 04/27/2025
8.0.0-preview.4.23259.5 18 04/27/2025
8.0.0-preview.3.23174.8 21 04/27/2025
8.0.0-preview.2.23128.3 22 04/27/2025
8.0.0-preview.1.23110.8 19 04/27/2025
7.0.0-rtm.22518.5 16 05/14/2025
7.0.0-rc.2.22472.3 18 04/27/2025
7.0.0-rc.1.22426.10 18 04/27/2025
7.0.0-preview.7.22375.6 19 04/27/2025
7.0.0-preview.6.22324.4 18 04/27/2025
7.0.0-preview.5.22301.12 18 04/27/2025
7.0.0-preview.4.22229.4 17 04/27/2025
7.0.0-preview.3.22175.4 19 04/27/2025
7.0.0-preview.2.22152.2 16 04/27/2025
7.0.0-preview.1.22076.8 19 04/27/2025
6.0.0-rtm.21522.10 16 04/27/2025
6.0.0-rc.2.21480.5 19 04/27/2025
6.0.0-rc.1.21451.13 16 04/27/2025
6.0.0-preview.7.21377.19 19 04/27/2025
6.0.0-preview.6.21352.12 18 04/27/2025
6.0.0-preview.5.21301.5 19 04/27/2025
6.0.0-preview.4.21253.7 20 05/30/2025
6.0.0-preview.3.21201.4 18 04/27/2025
6.0.0-preview.2.21154.6 16 04/27/2025
6.0.0-preview.1.21102.12 18 04/27/2025
5.0.0-preview.8.20407.11 19 04/27/2025
5.0.0-preview.7.20364.11 19 04/27/2025
5.0.0-preview.6.20305.6 23 04/27/2025
5.0.0-preview.5.20278.1 25 04/27/2025
5.0.0-preview.4.20251.6 20 04/27/2025
5.0.0-preview.3.20214.6 18 08/09/2025
5.0.0-preview.2.20160.6 16 04/27/2025
5.0.0-preview.1.20120.5 18 04/27/2025
0.2.0-preview7.19362.9 19 04/27/2025
0.2.0-preview6.19303.8 20 04/27/2025
0.2.0-preview6.19264.9 17 04/27/2025
0.2.0-preview5.19224.8 18 04/27/2025
0.2.0-preview4.19212.13 18 04/27/2025
0.2.0-preview3.19128.7 19 04/27/2025
0.2.0-preview.19073.11 20 04/27/2025
0.2.0-preview.18571.3 17 04/27/2025
0.1.0 20 04/27/2025