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)
4319
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMaxOperator<T>>(x);
4330
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMaxMagnitudeOperator<T>>(x);
4340
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMinOperator<T>>(x);
4352
return TensorOperation.IndexOfMinMax<T,
TensorPrimitives
.IndexOfMinMagnitudeOperator<T>>(x);
System\Numerics\Tensors\netcore\TensorOperation.cs (125)
470
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
476
return
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(AsDenseSpan(x));
484
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
544
return
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(flattened.AsSpan(0, (int)flattenedLength));
589
where TOperator : struct,
TensorPrimitives
.IIndexOfMinMaxOperator<T>
591
int index =
TensorPrimitives
.IndexOfMinMaxCore<T, TOperator>(values);
1652
TensorPrimitives
.Abs(x, destination);
1667
TensorPrimitives
.Acos(x, destination);
1682
TensorPrimitives
.Acosh(x, destination);
1697
TensorPrimitives
.AcosPi(x, destination);
1713
TensorPrimitives
.Add(x, y, destination);
1723
TensorPrimitives
.Add(x, y, destination);
1738
TensorPrimitives
.Asin(x, destination);
1753
TensorPrimitives
.Asinh(x, destination);
1768
TensorPrimitives
.AsinPi(x, destination);
1783
TensorPrimitives
.Atan(x, destination);
1813
TensorPrimitives
.Atan2(x, y, destination);
1856
TensorPrimitives
.Atan2Pi(x, y, destination);
1884
TensorPrimitives
.Atanh(x, destination);
1899
TensorPrimitives
.AtanPi(x, destination);
1915
TensorPrimitives
.BitwiseAnd(x, y, destination);
1925
TensorPrimitives
.BitwiseAnd(x, y, destination);
1941
TensorPrimitives
.BitwiseOr(x, y, destination);
1951
TensorPrimitives
.BitwiseOr(x, y, destination);
1966
TensorPrimitives
.Cbrt(x, destination);
1981
TensorPrimitives
.Ceiling(x, destination);
1997
TensorPrimitives
.ConvertChecked(x, destination);
2013
TensorPrimitives
.ConvertSaturating(x, destination);
2029
TensorPrimitives
.ConvertTruncating(x, destination);
2045
TensorPrimitives
.CopySign(x, y, destination);
2055
TensorPrimitives
.CopySign(x, y, destination);
2070
TensorPrimitives
.Cos(x, destination);
2085
TensorPrimitives
.Cosh(x, destination);
2104
destination[0].Item1 +=
TensorPrimitives
.Dot(x, y);
2105
destination[0].Item2 +=
TensorPrimitives
.SumOfSquares(x);
2106
destination[0].Item3 +=
TensorPrimitives
.SumOfSquares(y);
2121
TensorPrimitives
.CosPi(x, destination);
2137
TensorPrimitives
.Decrement(x, destination);
2152
TensorPrimitives
.DegreesToRadians(x, destination);
2169
TensorPrimitives
.Divide(x, y, destination);
2179
TensorPrimitives
.Divide(x, y, destination);
2188
TensorPrimitives
.Divide(x, y, destination);
2203
destination[0] +=
TensorPrimitives
.Dot(x, y);
2218
TensorPrimitives
.Exp(x, destination);
2233
TensorPrimitives
.Exp10(x, destination);
2248
TensorPrimitives
.Exp10M1(x, destination);
2263
TensorPrimitives
.Exp2(x, destination);
2278
TensorPrimitives
.Exp2M1(x, destination);
2293
TensorPrimitives
.ExpM1(x, destination);
2308
TensorPrimitives
.Floor(x, destination);
2323
TensorPrimitives
.Hypot(x, y, destination);
2340
TensorPrimitives
.Ieee754Remainder(x, y, destination);
2350
TensorPrimitives
.Ieee754Remainder(x, y, destination);
2359
TensorPrimitives
.Ieee754Remainder(x, y, destination);
2374
TensorPrimitives
.ILogB(x, destination);
2390
TensorPrimitives
.Increment(x, destination);
2405
TensorPrimitives
.LeadingZeroCount(x, destination);
2422
TensorPrimitives
.Log(x, destination);
2432
TensorPrimitives
.Log(x, y, destination);
2442
TensorPrimitives
.Log(x, y, destination);
2457
TensorPrimitives
.Log10(x, destination);
2472
TensorPrimitives
.Log10P1(x, destination);
2487
TensorPrimitives
.Log2(x, destination);
2502
TensorPrimitives
.Log2P1(x, destination);
2517
TensorPrimitives
.LogP1(x, destination);
2534
destination =
TensorPrimitives
.Max(x);
2544
TensorPrimitives
.Max(x, y, destination);
2554
TensorPrimitives
.Max(x, y, destination);
2571
destination =
TensorPrimitives
.MaxMagnitude(x);
2581
TensorPrimitives
.MaxMagnitude(x, y, destination);
2591
TensorPrimitives
.MaxMagnitude(x, y, destination);
2608
destination =
TensorPrimitives
.MaxMagnitudeNumber(x);
2618
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
2628
TensorPrimitives
.MaxMagnitudeNumber(x, y, destination);
2645
destination =
TensorPrimitives
.MaxNumber(x);
2655
TensorPrimitives
.MaxNumber(x, y, destination);
2665
TensorPrimitives
.MaxNumber(x, y, destination);
2682
destination =
TensorPrimitives
.Min(x);
2692
TensorPrimitives
.Min(x, y, destination);
2702
TensorPrimitives
.Min(x, y, destination);
2719
destination =
TensorPrimitives
.MinMagnitude(x);
2729
TensorPrimitives
.MinMagnitude(x, y, destination);
2739
TensorPrimitives
.MinMagnitude(x, y, destination);
2756
destination =
TensorPrimitives
.MinMagnitudeNumber(x);
2766
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
2776
TensorPrimitives
.MinMagnitudeNumber(x, y, destination);
2793
destination =
TensorPrimitives
.MinNumber(x);
2803
TensorPrimitives
.MinNumber(x, y, destination);
2813
TensorPrimitives
.MinNumber(x, y, destination);
2829
TensorPrimitives
.Multiply(x, y, destination);
2839
TensorPrimitives
.Multiply(x, y, destination);
2854
TensorPrimitives
.Negate(x, destination);
2869
TensorPrimitives
.OnesComplement(x, destination);
2884
TensorPrimitives
.PopCount(x, destination);
2901
TensorPrimitives
.Pow(x, y, destination);
2911
TensorPrimitives
.Pow(x, y, destination);
2921
TensorPrimitives
.Pow(x, y, destination);
2936
destination =
TensorPrimitives
.Product(x);
2951
TensorPrimitives
.RadiansToDegrees(x, destination);
2966
TensorPrimitives
.Reciprocal(x, destination);
2981
TensorPrimitives
.RootN(x, y, destination);
2995
TensorPrimitives
.RotateLeft(x, y, destination);
3009
TensorPrimitives
.RotateRight(x, y, destination);
3025
TensorPrimitives
.Round(x, destination);
3035
TensorPrimitives
.Round(x, y.Item1, y.Item2, destination);
3050
TensorPrimitives
.ShiftLeft(x, shiftAmount, destination);
3065
TensorPrimitives
.ShiftRightArithmetic(x, shiftAmount, destination);
3080
TensorPrimitives
.ShiftRightLogical(x, shiftAmount, destination);
3095
TensorPrimitives
.Sigmoid(x, destination);
3110
TensorPrimitives
.Sin(x, destination);
3125
TensorPrimitives
.Sinh(x, destination);
3140
TensorPrimitives
.SinPi(x, destination);
3226
TensorPrimitives
.Sqrt(x, destination);
3243
TensorPrimitives
.Subtract(x, y, destination);
3253
TensorPrimitives
.Subtract(x, y, destination);
3263
TensorPrimitives
.Subtract(x, y, destination);
3278
destination +=
TensorPrimitives
.Sum(x);
3344
destination +=
TensorPrimitives
.SumOfSquares(x);
3359
TensorPrimitives
.Tan(x, destination);
3374
TensorPrimitives
.Tanh(x, destination);
3389
TensorPrimitives
.TanPi(x, destination);
3404
TensorPrimitives
.TrailingZeroCount(x, destination);
3419
TensorPrimitives
.Truncate(x, destination);
3435
TensorPrimitives
.Xor(x, y, destination);
3445
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>;