199 references to TensorPrimitives
Microsoft.Data.Analysis (23)
Computations\Arithmetic.net8.cs (23)
76
public static void And(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.BitwiseAnd(x, y, destination);
77
public static void And(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.BitwiseAnd(x, y, destination);
78
public static void And(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.BitwiseAnd(y, x, destination);
79
public static void Or(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.BitwiseOr(x, y, destination);
80
public static void Or(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.BitwiseOr(x, y, destination);
81
public static void Or(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.BitwiseOr(y, x, destination);
82
public static void Xor(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Xor(x, y, destination);
83
public static void Xor(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.Xor(x, y, destination);
84
public static void Xor(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Xor(y, x, destination);
90
public static void LeftShift(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination) =>
TensorPrimitives
.ShiftLeft(x, shiftAmount, destination);
91
public static void RightShift(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination) =>
TensorPrimitives
.ShiftRightArithmetic(x, shiftAmount, destination);
97
public static void Add(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Add(x, y, destination);
98
public static void Add(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.Add(x, y, destination);
99
public static void Add(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Add(y, x, destination);
100
public static void Subtract(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Subtract(x, y, destination);
101
public static void Subtract(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.Subtract(x, y, destination);
102
public static void Subtract(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Subtract(x, y, destination);
103
public static void Multiply(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Multiply(x, y, destination);
104
public static void Multiply(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.Multiply(x, y, destination);
105
public static void Multiply(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Multiply(y, x, destination);
106
public static void Divide(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Divide(x, y, destination);
107
public static void Divide(ReadOnlySpan<T> x, T y, Span<T> destination) =>
TensorPrimitives
.Divide(x, y, destination);
108
public static void Divide(T x, ReadOnlySpan<T> y, Span<T> destination) =>
TensorPrimitives
.Divide(x, y, destination);
Microsoft.Extensions.AI (1)
ToolReduction\EmbeddingToolReductionStrategy.cs (1)
78
private Func<ReadOnlyMemory<float>, ReadOnlyMemory<float>, float> _similarity = static (a, b) =>
TensorPrimitives
.CosineSimilarity(a.Span, b.Span);
Microsoft.Extensions.AI.Integration.Tests (3)
EmbeddingGeneratorIntegrationTests.cs (2)
154
distances[i, j] =
TensorPrimitives
.HammingBitDistance<byte>(ToArray(embeddings[i].Vector), ToArray(embeddings[j].Vector));
198
distances[i, j] =
TensorPrimitives
.CosineSimilarity(embeddings[i].Vector.Span, embeddings[j].Vector.Span);
QuantizationEmbeddingGenerator.cs (1)
83
TensorPrimitives
.ConvertToHalf(vector, result);
Microsoft.Extensions.DataIngestion (1)
Chunkers\SemanticSimilarityChunker.cs (1)
88
float distance = 1 -
TensorPrimitives
.CosineSimilarity(embeddings[i].Vector.Span, embeddings[i + 1].Vector.Span);
Microsoft.ML.CpuMath (12)
CpuMathUtils.cs (11)
24
TensorPrimitives
.Add(destination, value, destination);
36
TensorPrimitives
.Multiply(destination, value, destination);
56
TensorPrimitives
.Multiply(source.Slice(0, count), value, destination);
75
TensorPrimitives
.MultiplyAdd(source.Slice(0, count), scale, destination.Slice(0, count), destination);
97
TensorPrimitives
.MultiplyAdd(source.Slice(0, count), scale, destination.Slice(0, count), result.Slice(0, count));
115
TensorPrimitives
.Add(source.Slice(0, count), destination.Slice(0, count), destination.Slice(0, count));
136
TensorPrimitives
.Multiply(left.Slice(0, count), right.Slice(0, count), destination.Slice(0, count));
149
return
TensorPrimitives
.Sum(source);
162
return
TensorPrimitives
.SumOfSquares(source);
175
return
TensorPrimitives
.SumOfMagnitudes(source);
194
return
TensorPrimitives
.Dot(left.Slice(0, count), right.Slice(0, count));
CpuMathUtils.netcoreapp.cs (1)
443
var value =
TensorPrimitives
.Distance(left.Slice(0, count), right.Slice(0, count));
System.Numerics.Tensors (159)
System\Numerics\Tensors\netcore\ReadOnlyTensorDimensionSpan_1.cs (1)
28
_length =
TensorPrimitives
.Product(tensor.Lengths[..dimension]);
System\Numerics\Tensors\netcore\Tensor.cs (12)
1418
nint tempLinear =
TensorPrimitives
.Product(newLengths);
1491
nint tempLinear =
TensorPrimitives
.Product(newLengths);
1568
nint tempLinear =
TensorPrimitives
.Product(newLengths);
1617
nint newSize =
TensorPrimitives
.Product(lengths);
3663
return
TensorPrimitives
.IndexOfMax(span);
3676
return
TensorPrimitives
.IndexOfMax<T>(flat.AsSpan(0, (int)x.FlattenedLength));
3695
return
TensorPrimitives
.IndexOfMaxMagnitude(span);
3708
return
TensorPrimitives
.IndexOfMaxMagnitude<T>(flat.AsSpan(0, (int)x.FlattenedLength));
3726
return
TensorPrimitives
.IndexOfMin(span);
3739
return
TensorPrimitives
.IndexOfMin<T>(flat.AsSpan(0, (int)x.FlattenedLength));
3759
return
TensorPrimitives
.IndexOfMinMagnitude(span);
3772
return
TensorPrimitives
.IndexOfMinMagnitude<T>(flat.AsSpan(0, (int)x.FlattenedLength));
System\Numerics\Tensors\netcore\TensorDimensionSpan_1.cs (1)
28
_length =
TensorPrimitives
.Product(tensor.Lengths[..dimension]);
System\Numerics\Tensors\netcore\TensorOperation.cs (119)
527
TensorPrimitives
.Abs(x, destination);
542
TensorPrimitives
.Acos(x, destination);
557
TensorPrimitives
.Acosh(x, destination);
572
TensorPrimitives
.AcosPi(x, destination);
588
TensorPrimitives
.Add(x, y, destination);
598
TensorPrimitives
.Add(x, y, destination);
613
TensorPrimitives
.Asin(x, destination);
628
TensorPrimitives
.Asinh(x, destination);
643
TensorPrimitives
.AsinPi(x, destination);
658
TensorPrimitives
.Atan(x, destination);
687
TensorPrimitives
.Atan2(x, y, destination);
716
TensorPrimitives
.Atan2Pi(x, y, destination);
731
TensorPrimitives
.Atanh(x, destination);
746
TensorPrimitives
.AtanPi(x, destination);
762
TensorPrimitives
.BitwiseAnd(x, y, destination);
772
TensorPrimitives
.BitwiseAnd(x, y, destination);
788
TensorPrimitives
.BitwiseOr(x, y, destination);
798
TensorPrimitives
.BitwiseOr(x, y, destination);
813
TensorPrimitives
.Cbrt(x, destination);
828
TensorPrimitives
.Ceiling(x, destination);
844
TensorPrimitives
.ConvertChecked(x, destination);
860
TensorPrimitives
.ConvertSaturating(x, destination);
876
TensorPrimitives
.ConvertTruncating(x, destination);
892
TensorPrimitives
.CopySign(x, y, destination);
902
TensorPrimitives
.CopySign(x, y, destination);
917
TensorPrimitives
.Cos(x, destination);
932
TensorPrimitives
.Cosh(x, destination);
951
destination[0].Item1 +=
TensorPrimitives
.Dot(x, y);
952
destination[0].Item2 +=
TensorPrimitives
.SumOfSquares(x);
953
destination[0].Item3 +=
TensorPrimitives
.SumOfSquares(y);
968
TensorPrimitives
.CosPi(x, destination);
984
TensorPrimitives
.Decrement(x, destination);
999
TensorPrimitives
.DegreesToRadians(x, destination);
1016
TensorPrimitives
.Divide(x, y, destination);
1026
TensorPrimitives
.Divide(x, y, destination);
1035
TensorPrimitives
.Divide(x, y, destination);
1050
destination[0] +=
TensorPrimitives
.Dot(x, y);
1065
TensorPrimitives
.Exp(x, destination);
1080
TensorPrimitives
.Exp10(x, destination);
1095
TensorPrimitives
.Exp10M1(x, destination);
1110
TensorPrimitives
.Exp2(x, destination);
1125
TensorPrimitives
.Exp2M1(x, destination);
1140
TensorPrimitives
.ExpM1(x, destination);
1155
TensorPrimitives
.Floor(x, destination);
1170
TensorPrimitives
.Hypot(x, y, destination);
1187
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1197
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1206
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1221
TensorPrimitives
.ILogB(x, destination);
1237
TensorPrimitives
.Increment(x, destination);
1252
TensorPrimitives
.LeadingZeroCount(x, destination);
1269
TensorPrimitives
.Log(x, destination);
1279
TensorPrimitives
.Log(x, y, destination);
1289
TensorPrimitives
.Log(x, y, destination);
1304
TensorPrimitives
.Log10(x, destination);
1319
TensorPrimitives
.Log10P1(x, destination);
1334
TensorPrimitives
.Log2(x, destination);
1349
TensorPrimitives
.Log2P1(x, destination);
1364
TensorPrimitives
.LogP1(x, destination);
1381
destination =
TensorPrimitives
.Max(x);
1391
TensorPrimitives
.Max(x, y, destination);
1401
TensorPrimitives
.Max(x, y, destination);
1418
destination =
TensorPrimitives
.MaxMagnitude(x);
1428
TensorPrimitives
.MaxMagnitude(x, y, destination);
1438
TensorPrimitives
.MaxMagnitude(x, y, destination);
1455
destination =
TensorPrimitives
.MaxMagnitudeNumber(x);
1465
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
1475
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
1492
destination =
TensorPrimitives
.MaxNumber(x);
1502
TensorPrimitives
.MaxNumber(x, y, destination);
1512
TensorPrimitives
.MaxNumber(x, y, destination);
1529
destination =
TensorPrimitives
.Min(x);
1539
TensorPrimitives
.Min(x, y, destination);
1549
TensorPrimitives
.Min(x, y, destination);
1566
destination =
TensorPrimitives
.MinMagnitude(x);
1576
TensorPrimitives
.MinMagnitude(x, y, destination);
1586
TensorPrimitives
.MinMagnitude(x, y, destination);
1603
destination =
TensorPrimitives
.MinMagnitudeNumber(x);
1613
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
1623
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
1640
destination =
TensorPrimitives
.MinNumber(x);
1650
TensorPrimitives
.MinNumber(x, y, destination);
1660
TensorPrimitives
.MinNumber(x, y, destination);
1676
TensorPrimitives
.Multiply(x, y, destination);
1686
TensorPrimitives
.Multiply(x, y, destination);
1701
TensorPrimitives
.Negate(x, destination);
1716
TensorPrimitives
.OnesComplement(x, destination);
1731
TensorPrimitives
.PopCount(x, destination);
1748
TensorPrimitives
.Pow(x, y, destination);
1758
TensorPrimitives
.Pow(x, y, destination);
1768
TensorPrimitives
.Pow(x, y, destination);
1783
destination =
TensorPrimitives
.Product(x);
1798
TensorPrimitives
.RadiansToDegrees(x, destination);
1813
TensorPrimitives
.Reciprocal(x, destination);
1828
TensorPrimitives
.RootN(x, y, destination);
1842
TensorPrimitives
.RotateLeft(x, y, destination);
1856
TensorPrimitives
.RotateRight(x, y, destination);
1872
TensorPrimitives
.Round(x, destination);
1882
TensorPrimitives
.Round(x, y.Item1, y.Item2, destination);
1897
TensorPrimitives
.ShiftLeft(x, shiftAmount, destination);
1912
TensorPrimitives
.ShiftRightArithmetic(x, shiftAmount, destination);
1927
TensorPrimitives
.ShiftRightLogical(x, shiftAmount, destination);
1942
TensorPrimitives
.Sigmoid(x, destination);
1957
TensorPrimitives
.Sin(x, destination);
1972
TensorPrimitives
.Sinh(x, destination);
1987
TensorPrimitives
.SinPi(x, destination);
2039
TensorPrimitives
.Sqrt(x, destination);
2056
TensorPrimitives
.Subtract(x, y, destination);
2066
TensorPrimitives
.Subtract(x, y, destination);
2076
TensorPrimitives
.Subtract(x, y, destination);
2091
destination +=
TensorPrimitives
.Sum(x);
2157
destination +=
TensorPrimitives
.SumOfSquares(x);
2172
TensorPrimitives
.Tan(x, destination);
2187
TensorPrimitives
.Tanh(x, destination);
2202
TensorPrimitives
.TanPi(x, destination);
2217
TensorPrimitives
.TrailingZeroCount(x, destination);
2232
TensorPrimitives
.Truncate(x, destination);
2248
TensorPrimitives
.Xor(x, y, destination);
2258
TensorPrimitives
.Xor(x, y, destination);
System\Numerics\Tensors\netcore\TensorPrimitives.Single.netcore.cs (26)
9
global using AbsoluteOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.AbsoluteOperator<float>;
10
global using AddOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.AddOperator<float>;
11
global using AddMultiplyOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.AddMultiplyOperator<float>;
12
global using CoshOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.CoshOperator<float>;
13
global using SubtractSquaredOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.SubtractSquaredOperator<float>;
14
global using DivideOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.DivideOperator<float>;
15
global using MultiplyOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MultiplyOperator<float>;
16
global using ExpOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.ExpOperator<float>;
17
global using IndexOfMaxOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.IndexOfMaxOperator<float>;
18
global using IndexOfMaxMagnitudeOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.IndexOfMaxMagnitudeOperator<float>;
19
global using IndexOfMinOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.IndexOfMinOperator<float>;
20
global using IndexOfMinMagnitudeOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.IndexOfMinMagnitudeOperator<float>;
21
global using LogOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.LogOperator<float>;
22
global using Log2Operator_Single = System.Numerics.Tensors.
TensorPrimitives
.Log2Operator<float>;
23
global using MaxOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MaxOperator<float>;
24
global using MaxMagnitudeOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MaxMagnitudeOperator<float>;
25
global using MinOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MinOperator<float>;
26
global using MinMagnitudeOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MinMagnitudeOperator<float>;
27
global using MultiplyAddOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.MultiplyAddOperator<float>;
28
global using NegateOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.NegateOperator<float>;
29
global using IdentityOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.IdentityOperator<float>;
30
global using SubtractOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.SubtractOperator<float>;
31
global using SigmoidOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.SigmoidOperator<float>;
32
global using SinhOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.SinhOperator<float>;
33
global using SquaredOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.SquaredOperator<float>;
34
global using TanhOperator_Single = System.Numerics.Tensors.
TensorPrimitives
.TanhOperator<float>;