Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/libraries/System.Numerics.Tensors/src/PACKAGE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
## 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.
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

* Numerical operations on tensors represented as `ReadOnlySpan<float>`
* 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

Expand All @@ -22,6 +25,7 @@ var movies = new[] {
};
var queryEmbedding = new[] { 0.12217915f, -0.034832448f };

// Using TensorPrimitives for low-level span operations
var top3MoviesTensorPrimitives =
movies
.Select(movie =>
Expand All @@ -36,13 +40,24 @@ 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`
* `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

Expand Down