196 references to TensorPrimitives
Microsoft.Data.Analysis (23)
Computations\Arithmetic.net8.cs (23)
76public static void And(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.BitwiseAnd(x, y, destination); 77public static void And(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.BitwiseAnd(x, y, destination); 78public static void And(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.BitwiseAnd(y, x, destination); 79public static void Or(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.BitwiseOr(x, y, destination); 80public static void Or(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.BitwiseOr(x, y, destination); 81public static void Or(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.BitwiseOr(y, x, destination); 82public static void Xor(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Xor(x, y, destination); 83public static void Xor(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.Xor(x, y, destination); 84public static void Xor(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Xor(y, x, destination); 90public static void LeftShift(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination) => TensorPrimitives.ShiftLeft(x, shiftAmount, destination); 91public static void RightShift(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination) => TensorPrimitives.ShiftRightArithmetic(x, shiftAmount, destination); 97public static void Add(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Add(x, y, destination); 98public static void Add(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.Add(x, y, destination); 99public static void Add(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Add(y, x, destination); 100public static void Subtract(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Subtract(x, y, destination); 101public static void Subtract(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.Subtract(x, y, destination); 102public static void Subtract(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Subtract(x, y, destination); 103public static void Multiply(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Multiply(x, y, destination); 104public static void Multiply(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.Multiply(x, y, destination); 105public static void Multiply(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Multiply(y, x, destination); 106public static void Divide(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Divide(x, y, destination); 107public static void Divide(ReadOnlySpan<T> x, T y, Span<T> destination) => TensorPrimitives.Divide(x, y, destination); 108public static void Divide(T x, ReadOnlySpan<T> y, Span<T> destination) => TensorPrimitives.Divide(x, y, destination);
Microsoft.Extensions.AI (2)
ChatRouting\SemanticRoutingChatClient.cs (2)
208float score = TensorPrimitives.CosineSimilarity(queryVector, profile.Vector); 226TensorPrimitives.CosineSimilarity(queryVector, index[i].Vector));
Microsoft.Extensions.AI.Integration.Tests (3)
EmbeddingGeneratorIntegrationTests.cs (2)
153distances[i, j] = TensorPrimitives.HammingBitDistance<byte>(ToArray(embeddings[i].Vector), ToArray(embeddings[j].Vector)); 197distances[i, j] = TensorPrimitives.CosineSimilarity(embeddings[i].Vector.Span, embeddings[j].Vector.Span);
QuantizationEmbeddingGenerator.cs (1)
83TensorPrimitives.ConvertToHalf(vector, result);
Microsoft.Extensions.DataIngestion (1)
Chunkers\SemanticSimilarityChunker.cs (1)
88float distance = 1 - TensorPrimitives.CosineSimilarity(embeddings[i].Vector.Span, embeddings[i + 1].Vector.Span);
Microsoft.ML.CpuMath (12)
CpuMathUtils.cs (11)
24TensorPrimitives.Add(destination, value, destination); 36TensorPrimitives.Multiply(destination, value, destination); 56TensorPrimitives.Multiply(source.Slice(0, count), value, destination); 75TensorPrimitives.MultiplyAdd(source.Slice(0, count), scale, destination.Slice(0, count), destination); 97TensorPrimitives.MultiplyAdd(source.Slice(0, count), scale, destination.Slice(0, count), result.Slice(0, count)); 115TensorPrimitives.Add(source.Slice(0, count), destination.Slice(0, count), destination.Slice(0, count)); 136TensorPrimitives.Multiply(left.Slice(0, count), right.Slice(0, count), destination.Slice(0, count)); 149return TensorPrimitives.Sum(source); 162return TensorPrimitives.SumOfSquares(source); 175return TensorPrimitives.SumOfMagnitudes(source); 194return TensorPrimitives.Dot(left.Slice(0, count), right.Slice(0, count));
CpuMathUtils.netcoreapp.cs (1)
443var value = TensorPrimitives.Distance(left.Slice(0, count), right.Slice(0, count));
System.Numerics.Tensors (155)
System\Numerics\Tensors\netcore\Tensor.cs (4)
4319return TensorOperation.IndexOfMinMax<T, TensorPrimitives.IndexOfMaxOperator<T>>(x); 4330return TensorOperation.IndexOfMinMax<T, TensorPrimitives.IndexOfMaxMagnitudeOperator<T>>(x); 4340return TensorOperation.IndexOfMinMax<T, TensorPrimitives.IndexOfMinOperator<T>>(x); 4352return TensorOperation.IndexOfMinMax<T, TensorPrimitives.IndexOfMinMagnitudeOperator<T>>(x);
System\Numerics\Tensors\netcore\TensorOperation.cs (125)
470where TOperator : struct, TensorPrimitives.IIndexOfMinMaxOperator<T> 476return TensorPrimitives.IndexOfMinMaxCore<T, TOperator>(AsDenseSpan(x)); 484where TOperator : struct, TensorPrimitives.IIndexOfMinMaxOperator<T> 544return TensorPrimitives.IndexOfMinMaxCore<T, TOperator>(flattened.AsSpan(0, (int)flattenedLength)); 589where TOperator : struct, TensorPrimitives.IIndexOfMinMaxOperator<T> 591int index = TensorPrimitives.IndexOfMinMaxCore<T, TOperator>(values); 1652TensorPrimitives.Abs(x, destination); 1667TensorPrimitives.Acos(x, destination); 1682TensorPrimitives.Acosh(x, destination); 1697TensorPrimitives.AcosPi(x, destination); 1713TensorPrimitives.Add(x, y, destination); 1723TensorPrimitives.Add(x, y, destination); 1738TensorPrimitives.Asin(x, destination); 1753TensorPrimitives.Asinh(x, destination); 1768TensorPrimitives.AsinPi(x, destination); 1783TensorPrimitives.Atan(x, destination); 1813TensorPrimitives.Atan2(x, y, destination); 1856TensorPrimitives.Atan2Pi(x, y, destination); 1884TensorPrimitives.Atanh(x, destination); 1899TensorPrimitives.AtanPi(x, destination); 1915TensorPrimitives.BitwiseAnd(x, y, destination); 1925TensorPrimitives.BitwiseAnd(x, y, destination); 1941TensorPrimitives.BitwiseOr(x, y, destination); 1951TensorPrimitives.BitwiseOr(x, y, destination); 1966TensorPrimitives.Cbrt(x, destination); 1981TensorPrimitives.Ceiling(x, destination); 1997TensorPrimitives.ConvertChecked(x, destination); 2013TensorPrimitives.ConvertSaturating(x, destination); 2029TensorPrimitives.ConvertTruncating(x, destination); 2045TensorPrimitives.CopySign(x, y, destination); 2055TensorPrimitives.CopySign(x, y, destination); 2070TensorPrimitives.Cos(x, destination); 2085TensorPrimitives.Cosh(x, destination); 2104destination[0].Item1 += TensorPrimitives.Dot(x, y); 2105destination[0].Item2 += TensorPrimitives.SumOfSquares(x); 2106destination[0].Item3 += TensorPrimitives.SumOfSquares(y); 2121TensorPrimitives.CosPi(x, destination); 2137TensorPrimitives.Decrement(x, destination); 2152TensorPrimitives.DegreesToRadians(x, destination); 2169TensorPrimitives.Divide(x, y, destination); 2179TensorPrimitives.Divide(x, y, destination); 2188TensorPrimitives.Divide(x, y, destination); 2203destination[0] += TensorPrimitives.Dot(x, y); 2218TensorPrimitives.Exp(x, destination); 2233TensorPrimitives.Exp10(x, destination); 2248TensorPrimitives.Exp10M1(x, destination); 2263TensorPrimitives.Exp2(x, destination); 2278TensorPrimitives.Exp2M1(x, destination); 2293TensorPrimitives.ExpM1(x, destination); 2308TensorPrimitives.Floor(x, destination); 2323TensorPrimitives.Hypot(x, y, destination); 2340TensorPrimitives.Ieee754Remainder(x, y, destination); 2350TensorPrimitives.Ieee754Remainder(x, y, destination); 2359TensorPrimitives.Ieee754Remainder(x, y, destination); 2374TensorPrimitives.ILogB(x, destination); 2390TensorPrimitives.Increment(x, destination); 2405TensorPrimitives.LeadingZeroCount(x, destination); 2422TensorPrimitives.Log(x, destination); 2432TensorPrimitives.Log(x, y, destination); 2442TensorPrimitives.Log(x, y, destination); 2457TensorPrimitives.Log10(x, destination); 2472TensorPrimitives.Log10P1(x, destination); 2487TensorPrimitives.Log2(x, destination); 2502TensorPrimitives.Log2P1(x, destination); 2517TensorPrimitives.LogP1(x, destination); 2534destination = TensorPrimitives.Max(x); 2544TensorPrimitives.Max(x, y, destination); 2554TensorPrimitives.Max(x, y, destination); 2571destination = TensorPrimitives.MaxMagnitude(x); 2581TensorPrimitives.MaxMagnitude(x, y, destination); 2591TensorPrimitives.MaxMagnitude(x, y, destination); 2608destination = TensorPrimitives.MaxMagnitudeNumber(x); 2618TensorPrimitives.MaxMagnitudeNumber(x, y, destination); 2628TensorPrimitives.MaxMagnitudeNumber(x, y, destination); 2645destination = TensorPrimitives.MaxNumber(x); 2655TensorPrimitives.MaxNumber(x, y, destination); 2665TensorPrimitives.MaxNumber(x, y, destination); 2682destination = TensorPrimitives.Min(x); 2692TensorPrimitives.Min(x, y, destination); 2702TensorPrimitives.Min(x, y, destination); 2719destination = TensorPrimitives.MinMagnitude(x); 2729TensorPrimitives.MinMagnitude(x, y, destination); 2739TensorPrimitives.MinMagnitude(x, y, destination); 2756destination = TensorPrimitives.MinMagnitudeNumber(x); 2766TensorPrimitives.MinMagnitudeNumber(x, y, destination); 2776TensorPrimitives.MinMagnitudeNumber(x, y, destination); 2793destination = TensorPrimitives.MinNumber(x); 2803TensorPrimitives.MinNumber(x, y, destination); 2813TensorPrimitives.MinNumber(x, y, destination); 2829TensorPrimitives.Multiply(x, y, destination); 2839TensorPrimitives.Multiply(x, y, destination); 2854TensorPrimitives.Negate(x, destination); 2869TensorPrimitives.OnesComplement(x, destination); 2884TensorPrimitives.PopCount(x, destination); 2901TensorPrimitives.Pow(x, y, destination); 2911TensorPrimitives.Pow(x, y, destination); 2921TensorPrimitives.Pow(x, y, destination); 2936destination = TensorPrimitives.Product(x); 2951TensorPrimitives.RadiansToDegrees(x, destination); 2966TensorPrimitives.Reciprocal(x, destination); 2981TensorPrimitives.RootN(x, y, destination); 2995TensorPrimitives.RotateLeft(x, y, destination); 3009TensorPrimitives.RotateRight(x, y, destination); 3025TensorPrimitives.Round(x, destination); 3035TensorPrimitives.Round(x, y.Item1, y.Item2, destination); 3050TensorPrimitives.ShiftLeft(x, shiftAmount, destination); 3065TensorPrimitives.ShiftRightArithmetic(x, shiftAmount, destination); 3080TensorPrimitives.ShiftRightLogical(x, shiftAmount, destination); 3095TensorPrimitives.Sigmoid(x, destination); 3110TensorPrimitives.Sin(x, destination); 3125TensorPrimitives.Sinh(x, destination); 3140TensorPrimitives.SinPi(x, destination); 3226TensorPrimitives.Sqrt(x, destination); 3243TensorPrimitives.Subtract(x, y, destination); 3253TensorPrimitives.Subtract(x, y, destination); 3263TensorPrimitives.Subtract(x, y, destination); 3278destination += TensorPrimitives.Sum(x); 3344destination += TensorPrimitives.SumOfSquares(x); 3359TensorPrimitives.Tan(x, destination); 3374TensorPrimitives.Tanh(x, destination); 3389TensorPrimitives.TanPi(x, destination); 3404TensorPrimitives.TrailingZeroCount(x, destination); 3419TensorPrimitives.Truncate(x, destination); 3435TensorPrimitives.Xor(x, y, destination); 3445TensorPrimitives.Xor(x, y, destination);
System\Numerics\Tensors\netcore\TensorPrimitives.Single.netcore.cs (26)
9global using AbsoluteOperator_Single = System.Numerics.Tensors.TensorPrimitives.AbsoluteOperator<float>; 10global using AddOperator_Single = System.Numerics.Tensors.TensorPrimitives.AddOperator<float>; 11global using AddMultiplyOperator_Single = System.Numerics.Tensors.TensorPrimitives.AddMultiplyOperator<float>; 12global using CoshOperator_Single = System.Numerics.Tensors.TensorPrimitives.CoshOperator<float>; 13global using SubtractSquaredOperator_Single = System.Numerics.Tensors.TensorPrimitives.SubtractSquaredOperator<float>; 14global using DivideOperator_Single = System.Numerics.Tensors.TensorPrimitives.DivideOperator<float>; 15global using MultiplyOperator_Single = System.Numerics.Tensors.TensorPrimitives.MultiplyOperator<float>; 16global using ExpOperator_Single = System.Numerics.Tensors.TensorPrimitives.ExpOperator<float>; 17global using IndexOfMaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxOperator<float>; 18global using IndexOfMaxMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxMagnitudeOperator<float>; 19global using IndexOfMinOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinOperator<float>; 20global using IndexOfMinMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinMagnitudeOperator<float>; 21global using LogOperator_Single = System.Numerics.Tensors.TensorPrimitives.LogOperator<float>; 22global using Log2Operator_Single = System.Numerics.Tensors.TensorPrimitives.Log2Operator<float>; 23global using MaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxOperator<float>; 24global using MaxMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxMagnitudeOperator<float>; 25global using MinOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinOperator<float>; 26global using MinMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinMagnitudeOperator<float>; 27global using MultiplyAddOperator_Single = System.Numerics.Tensors.TensorPrimitives.MultiplyAddOperator<float>; 28global using NegateOperator_Single = System.Numerics.Tensors.TensorPrimitives.NegateOperator<float>; 29global using IdentityOperator_Single = System.Numerics.Tensors.TensorPrimitives.IdentityOperator<float>; 30global using SubtractOperator_Single = System.Numerics.Tensors.TensorPrimitives.SubtractOperator<float>; 31global using SigmoidOperator_Single = System.Numerics.Tensors.TensorPrimitives.SigmoidOperator<float>; 32global using SinhOperator_Single = System.Numerics.Tensors.TensorPrimitives.SinhOperator<float>; 33global using SquaredOperator_Single = System.Numerics.Tensors.TensorPrimitives.SquaredOperator<float>; 34global using TanhOperator_Single = System.Numerics.Tensors.TensorPrimitives.TanhOperator<float>;