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