Skip to content

Commit 5688eab

Browse files
Copilotstephentoubtannergooding
authored
Update System.Numerics.Tensors PACKAGE.md to reflect current library capabilities (#118512)
* Initial plan * Update System.Numerics.Tensors PACKAGE.md to reflect current library capabilities Co-authored-by: stephentoub <[email protected]> * Update src/libraries/System.Numerics.Tensors/src/PACKAGE.md Co-authored-by: Tanner Gooding <[email protected]> * Fix trailing spaces in PACKAGE.md markdown linting issue Co-authored-by: stephentoub <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: stephentoub <[email protected]> Co-authored-by: Stephen Toub <[email protected]> Co-authored-by: Tanner Gooding <[email protected]>
1 parent 19e2ae0 commit 5688eab

File tree

1 file changed

+18
-3
lines changed
  • src/libraries/System.Numerics.Tensors/src

1 file changed

+18
-3
lines changed

src/libraries/System.Numerics.Tensors/src/PACKAGE.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
## About
22

3-
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.
3+
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.
44

55
## Key Features
66

7-
* Numerical operations on tensors represented as `ReadOnlySpan<float>`
7+
* High-level tensor types: `Tensor<T>`, `TensorSpan<T>`, `ReadOnlyTensorSpan<T>` for working with multi-dimensional arrays
8+
* Low-level tensor primitives: `TensorPrimitives` for efficient span-based operations
9+
* Generic support for various numeric types (float, double, int, etc.)
810
* Element-wise arithmetic: Add, Subtract, Multiply, Divide, Exp, Log, Cosh, Tanh, etc.
911
* Tensor arithmetic: CosineSimilarity, Distance, Dot, Normalize, Softmax, Sigmoid, etc.
12+
* SIMD-accelerated operations for improved performance
1013

1114
## How to Use
1215

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

28+
// Using TensorPrimitives for low-level span operations
2529
var top3MoviesTensorPrimitives =
2630
movies
2731
.Select(movie =>
@@ -36,13 +40,24 @@ foreach (var movie in top3MoviesTensorPrimitives)
3640
{
3741
Console.WriteLine(movie);
3842
}
43+
44+
// Using higher-level Tensor types for multi-dimensional operations
45+
float[] data1 = [1f, 2f, 3f, 4f, 5f, 6f];
46+
float[] data2 = [6f, 5f, 4f, 3f, 2f, 1f];
47+
Tensor<float> tensor1 = Tensor.Create(data1, [2, 3]); // 2x3 tensor
48+
Tensor<float> tensor2 = Tensor.Create(data2, [2, 3]); // 2x3 tensor
49+
Tensor<float> result = tensor1 + tensor2;
3950
```
4051

4152
## Main Types
4253

4354
The main types provided by this library are:
4455

45-
* `System.Numerics.Tensors.TensorPrimitives`
56+
* `System.Numerics.Tensors.TensorPrimitives` - Low-level operations on spans of numeric data
57+
* `System.Numerics.Tensors.Tensor<T>` - Generic tensor class for multi-dimensional arrays
58+
* `System.Numerics.Tensors.TensorSpan<T>` - Span-like view over tensor data
59+
* `System.Numerics.Tensors.ReadOnlyTensorSpan<T>` - Read-only span-like view over tensor data
60+
* `System.Numerics.Tensors.Tensor` - Static class with high-level tensor operations
4661

4762
## Additional Documentation
4863

0 commit comments

Comments
 (0)