System.Numerics.Tensors 11.0.0

About

Provides methods for performing mathematical operations over tensors. This library offers both high-level tensor types and low-level primitives for working with multi-dimensional numeric data. Many operations are accelerated to use SIMD (Single instruction, multiple data) operations supported by the CPU where available.

Key Features

  • High-level tensor types: Tensor<T>, TensorSpan<T>, ReadOnlyTensorSpan<T> for working with multi-dimensional arrays
  • Low-level tensor primitives: TensorPrimitives for efficient span-based operations
  • Generic support for various numeric types (float, double, int, etc.)
  • Element-wise arithmetic: Add, Subtract, Multiply, Divide, Exp, Log, Cosh, Tanh, etc.
  • Tensor arithmetic: CosineSimilarity, Distance, Dot, Normalize, Softmax, Sigmoid, etc.
  • SIMD-accelerated operations for improved performance

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 };

// Using TensorPrimitives for low-level span operations
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);
}

// Using higher-level Tensor types for multi-dimensional operations
float[] data1 = [1f, 2f, 3f, 4f, 5f, 6f];
float[] data2 = [6f, 5f, 4f, 3f, 2f, 1f];
Tensor<float> tensor1 = Tensor.Create(data1, [2, 3]); // 2x3 tensor
Tensor<float> tensor2 = Tensor.Create(data2, [2, 3]); // 2x3 tensor
Tensor<float> result = tensor1 + tensor2;

Main Types

The main types provided by this library are:

  • System.Numerics.Tensors.TensorPrimitives - Low-level operations on spans of numeric data
  • System.Numerics.Tensors.Tensor<T> - Generic tensor class for multi-dimensional arrays
  • System.Numerics.Tensors.TensorSpan<T> - Span-like view over tensor data
  • System.Numerics.Tensors.ReadOnlyTensorSpan<T> - Read-only span-like view over tensor data
  • System.Numerics.Tensors.Tensor - Static class with high-level tensor operations

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.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
16
Microsoft.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
15
Microsoft.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
14
Microsoft.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
13
LM-Kit.NET
Private AI for documents and internal knowledge in .NET: agents, RAG, OCR, structured extraction, vision, speech and embeddings, fully local in one NuGet.
13
Microsoft.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
12
Microsoft.Extensions.AI
Utilities for working with generative AI components.
12
LM-Kit.NET
Enterprise-grade .NET platform for builders who need AI agents, document intelligence, and full data control.
12
Microsoft.Data.Analysis
This package contains easy-to-use and high-performance libraries for data analysis and transformation.
10
Microsoft.Extensions.AI
Utilities for working with generative AI components.
10
LM-Kit.NET
Enterprise-Grade .NET SDK for Integrating Generative AI Capabilities.
10

.NET 10.0

  • No dependencies.

.NET 11.0

  • No dependencies.

.NET Framework 4.6.2

.NET Standard 2.0

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