196 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 (2)
ChatRouting\SemanticRoutingChatClient.cs (2)
208
float score =
TensorPrimitives
.CosineSimilarity(queryVector, profile.Vector);
226
TensorPrimitives
.CosineSimilarity(queryVector, index[i].Vector));
Microsoft.Extensions.AI.Integration.Tests (3)
EmbeddingGeneratorIntegrationTests.cs (2)
153
distances[i, j] =
TensorPrimitives
.HammingBitDistance<byte>(ToArray(embeddings[i].Vector), ToArray(embeddings[j].Vector));
197
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 (155)
System\Numerics\Tensors\netcore\Tensor.cs (4)
4008
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMaxOperator<T>>(x);
4019
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMaxMagnitudeOperator<T>>(x);
4029
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMinOperator<T>>(x);
4041
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMinMagnitudeOperator<T>>(x);
System\Numerics\Tensors\netcore\TensorOperation.cs (125)
145
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
151
return
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(AsDenseSpan(x));
159
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
219
return
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(flattened.AsSpan(0, (int)flattenedLength));
264
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
266
int index =
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(values);
1030
TensorPrimitives
.Abs(x, destination);
1045
TensorPrimitives
.Acos(x, destination);
1060
TensorPrimitives
.Acosh(x, destination);
1075
TensorPrimitives
.AcosPi(x, destination);
1091
TensorPrimitives
.Add(x, y, destination);
1101
TensorPrimitives
.Add(x, y, destination);
1116
TensorPrimitives
.Asin(x, destination);
1131
TensorPrimitives
.Asinh(x, destination);
1146
TensorPrimitives
.AsinPi(x, destination);
1161
TensorPrimitives
.Atan(x, destination);
1191
TensorPrimitives
.Atan2(x, y, destination);
1234
TensorPrimitives
.Atan2Pi(x, y, destination);
1262
TensorPrimitives
.Atanh(x, destination);
1277
TensorPrimitives
.AtanPi(x, destination);
1293
TensorPrimitives
.BitwiseAnd(x, y, destination);
1303
TensorPrimitives
.BitwiseAnd(x, y, destination);
1319
TensorPrimitives
.BitwiseOr(x, y, destination);
1329
TensorPrimitives
.BitwiseOr(x, y, destination);
1344
TensorPrimitives
.Cbrt(x, destination);
1359
TensorPrimitives
.Ceiling(x, destination);
1375
TensorPrimitives
.ConvertChecked(x, destination);
1391
TensorPrimitives
.ConvertSaturating(x, destination);
1407
TensorPrimitives
.ConvertTruncating(x, destination);
1423
TensorPrimitives
.CopySign(x, y, destination);
1433
TensorPrimitives
.CopySign(x, y, destination);
1448
TensorPrimitives
.Cos(x, destination);
1463
TensorPrimitives
.Cosh(x, destination);
1482
destination[0].Item1 +=
TensorPrimitives
.Dot(x, y);
1483
destination[0].Item2 +=
TensorPrimitives
.SumOfSquares(x);
1484
destination[0].Item3 +=
TensorPrimitives
.SumOfSquares(y);
1499
TensorPrimitives
.CosPi(x, destination);
1515
TensorPrimitives
.Decrement(x, destination);
1530
TensorPrimitives
.DegreesToRadians(x, destination);
1547
TensorPrimitives
.Divide(x, y, destination);
1557
TensorPrimitives
.Divide(x, y, destination);
1566
TensorPrimitives
.Divide(x, y, destination);
1581
destination[0] +=
TensorPrimitives
.Dot(x, y);
1596
TensorPrimitives
.Exp(x, destination);
1611
TensorPrimitives
.Exp10(x, destination);
1626
TensorPrimitives
.Exp10M1(x, destination);
1641
TensorPrimitives
.Exp2(x, destination);
1656
TensorPrimitives
.Exp2M1(x, destination);
1671
TensorPrimitives
.ExpM1(x, destination);
1686
TensorPrimitives
.Floor(x, destination);
1701
TensorPrimitives
.Hypot(x, y, destination);
1718
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1728
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1737
TensorPrimitives
.Ieee754Remainder(x, y, destination);
1752
TensorPrimitives
.ILogB(x, destination);
1768
TensorPrimitives
.Increment(x, destination);
1783
TensorPrimitives
.LeadingZeroCount(x, destination);
1800
TensorPrimitives
.Log(x, destination);
1810
TensorPrimitives
.Log(x, y, destination);
1820
TensorPrimitives
.Log(x, y, destination);
1835
TensorPrimitives
.Log10(x, destination);
1850
TensorPrimitives
.Log10P1(x, destination);
1865
TensorPrimitives
.Log2(x, destination);
1880
TensorPrimitives
.Log2P1(x, destination);
1895
TensorPrimitives
.LogP1(x, destination);
1912
destination =
TensorPrimitives
.Max(x);
1922
TensorPrimitives
.Max(x, y, destination);
1932
TensorPrimitives
.Max(x, y, destination);
1949
destination =
TensorPrimitives
.MaxMagnitude(x);
1959
TensorPrimitives
.MaxMagnitude(x, y, destination);
1969
TensorPrimitives
.MaxMagnitude(x, y, destination);
1986
destination =
TensorPrimitives
.MaxMagnitudeNumber(x);
1996
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
2006
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
2023
destination =
TensorPrimitives
.MaxNumber(x);
2033
TensorPrimitives
.MaxNumber(x, y, destination);
2043
TensorPrimitives
.MaxNumber(x, y, destination);
2060
destination =
TensorPrimitives
.Min(x);
2070
TensorPrimitives
.Min(x, y, destination);
2080
TensorPrimitives
.Min(x, y, destination);
2097
destination =
TensorPrimitives
.MinMagnitude(x);
2107
TensorPrimitives
.MinMagnitude(x, y, destination);
2117
TensorPrimitives
.MinMagnitude(x, y, destination);
2134
destination =
TensorPrimitives
.MinMagnitudeNumber(x);
2144
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
2154
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
2171
destination =
TensorPrimitives
.MinNumber(x);
2181
TensorPrimitives
.MinNumber(x, y, destination);
2191
TensorPrimitives
.MinNumber(x, y, destination);
2207
TensorPrimitives
.Multiply(x, y, destination);
2217
TensorPrimitives
.Multiply(x, y, destination);
2232
TensorPrimitives
.Negate(x, destination);
2247
TensorPrimitives
.OnesComplement(x, destination);
2262
TensorPrimitives
.PopCount(x, destination);
2279
TensorPrimitives
.Pow(x, y, destination);
2289
TensorPrimitives
.Pow(x, y, destination);
2299
TensorPrimitives
.Pow(x, y, destination);
2314
destination =
TensorPrimitives
.Product(x);
2329
TensorPrimitives
.RadiansToDegrees(x, destination);
2344
TensorPrimitives
.Reciprocal(x, destination);
2359
TensorPrimitives
.RootN(x, y, destination);
2373
TensorPrimitives
.RotateLeft(x, y, destination);
2387
TensorPrimitives
.RotateRight(x, y, destination);
2403
TensorPrimitives
.Round(x, destination);
2413
TensorPrimitives
.Round(x, y.Item1, y.Item2, destination);
2428
TensorPrimitives
.ShiftLeft(x, shiftAmount, destination);
2443
TensorPrimitives
.ShiftRightArithmetic(x, shiftAmount, destination);
2458
TensorPrimitives
.ShiftRightLogical(x, shiftAmount, destination);
2473
TensorPrimitives
.Sigmoid(x, destination);
2488
TensorPrimitives
.Sin(x, destination);
2503
TensorPrimitives
.Sinh(x, destination);
2518
TensorPrimitives
.SinPi(x, destination);
2604
TensorPrimitives
.Sqrt(x, destination);
2621
TensorPrimitives
.Subtract(x, y, destination);
2631
TensorPrimitives
.Subtract(x, y, destination);
2641
TensorPrimitives
.Subtract(x, y, destination);
2656
destination +=
TensorPrimitives
.Sum(x);
2722
destination +=
TensorPrimitives
.SumOfSquares(x);
2737
TensorPrimitives
.Tan(x, destination);
2752
TensorPrimitives
.Tanh(x, destination);
2767
TensorPrimitives
.TanPi(x, destination);
2782
TensorPrimitives
.TrailingZeroCount(x, destination);
2797
TensorPrimitives
.Truncate(x, destination);
2813
TensorPrimitives
.Xor(x, y, destination);
2823
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>;