199 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 (1)
ToolReduction\EmbeddingToolReductionStrategy.cs (1)
78private 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)
154distances[i, j] = TensorPrimitives.HammingBitDistance<byte>(ToArray(embeddings[i].Vector), ToArray(embeddings[j].Vector)); 198distances[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 (159)
System\Numerics\Tensors\netcore\ReadOnlyTensorDimensionSpan_1.cs (1)
28_length = TensorPrimitives.Product(tensor.Lengths[..dimension]);
System\Numerics\Tensors\netcore\Tensor.cs (12)
1418nint tempLinear = TensorPrimitives.Product(newLengths); 1491nint tempLinear = TensorPrimitives.Product(newLengths); 1568nint tempLinear = TensorPrimitives.Product(newLengths); 1617nint newSize = TensorPrimitives.Product(lengths); 3663return TensorPrimitives.IndexOfMax(span); 3676return TensorPrimitives.IndexOfMax<T>(flat.AsSpan(0, (int)x.FlattenedLength)); 3695return TensorPrimitives.IndexOfMaxMagnitude(span); 3708return TensorPrimitives.IndexOfMaxMagnitude<T>(flat.AsSpan(0, (int)x.FlattenedLength)); 3726return TensorPrimitives.IndexOfMin(span); 3739return TensorPrimitives.IndexOfMin<T>(flat.AsSpan(0, (int)x.FlattenedLength)); 3759return TensorPrimitives.IndexOfMinMagnitude(span); 3772return 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)
527TensorPrimitives.Abs(x, destination); 542TensorPrimitives.Acos(x, destination); 557TensorPrimitives.Acosh(x, destination); 572TensorPrimitives.AcosPi(x, destination); 588TensorPrimitives.Add(x, y, destination); 598TensorPrimitives.Add(x, y, destination); 613TensorPrimitives.Asin(x, destination); 628TensorPrimitives.Asinh(x, destination); 643TensorPrimitives.AsinPi(x, destination); 658TensorPrimitives.Atan(x, destination); 687TensorPrimitives.Atan2(x, y, destination); 716TensorPrimitives.Atan2Pi(x, y, destination); 731TensorPrimitives.Atanh(x, destination); 746TensorPrimitives.AtanPi(x, destination); 762TensorPrimitives.BitwiseAnd(x, y, destination); 772TensorPrimitives.BitwiseAnd(x, y, destination); 788TensorPrimitives.BitwiseOr(x, y, destination); 798TensorPrimitives.BitwiseOr(x, y, destination); 813TensorPrimitives.Cbrt(x, destination); 828TensorPrimitives.Ceiling(x, destination); 844TensorPrimitives.ConvertChecked(x, destination); 860TensorPrimitives.ConvertSaturating(x, destination); 876TensorPrimitives.ConvertTruncating(x, destination); 892TensorPrimitives.CopySign(x, y, destination); 902TensorPrimitives.CopySign(x, y, destination); 917TensorPrimitives.Cos(x, destination); 932TensorPrimitives.Cosh(x, destination); 951destination[0].Item1 += TensorPrimitives.Dot(x, y); 952destination[0].Item2 += TensorPrimitives.SumOfSquares(x); 953destination[0].Item3 += TensorPrimitives.SumOfSquares(y); 968TensorPrimitives.CosPi(x, destination); 984TensorPrimitives.Decrement(x, destination); 999TensorPrimitives.DegreesToRadians(x, destination); 1016TensorPrimitives.Divide(x, y, destination); 1026TensorPrimitives.Divide(x, y, destination); 1035TensorPrimitives.Divide(x, y, destination); 1050destination[0] += TensorPrimitives.Dot(x, y); 1065TensorPrimitives.Exp(x, destination); 1080TensorPrimitives.Exp10(x, destination); 1095TensorPrimitives.Exp10M1(x, destination); 1110TensorPrimitives.Exp2(x, destination); 1125TensorPrimitives.Exp2M1(x, destination); 1140TensorPrimitives.ExpM1(x, destination); 1155TensorPrimitives.Floor(x, destination); 1170TensorPrimitives.Hypot(x, y, destination); 1187TensorPrimitives.Ieee754Remainder(x, y, destination); 1197TensorPrimitives.Ieee754Remainder(x, y, destination); 1206TensorPrimitives.Ieee754Remainder(x, y, destination); 1221TensorPrimitives.ILogB(x, destination); 1237TensorPrimitives.Increment(x, destination); 1252TensorPrimitives.LeadingZeroCount(x, destination); 1269TensorPrimitives.Log(x, destination); 1279TensorPrimitives.Log(x, y, destination); 1289TensorPrimitives.Log(x, y, destination); 1304TensorPrimitives.Log10(x, destination); 1319TensorPrimitives.Log10P1(x, destination); 1334TensorPrimitives.Log2(x, destination); 1349TensorPrimitives.Log2P1(x, destination); 1364TensorPrimitives.LogP1(x, destination); 1381destination = TensorPrimitives.Max(x); 1391TensorPrimitives.Max(x, y, destination); 1401TensorPrimitives.Max(x, y, destination); 1418destination = TensorPrimitives.MaxMagnitude(x); 1428TensorPrimitives.MaxMagnitude(x, y, destination); 1438TensorPrimitives.MaxMagnitude(x, y, destination); 1455destination = TensorPrimitives.MaxMagnitudeNumber(x); 1465TensorPrimitives.MaxMagnitudeNumber(x, y, destination); 1475TensorPrimitives.MaxMagnitudeNumber(x, y, destination); 1492destination = TensorPrimitives.MaxNumber(x); 1502TensorPrimitives.MaxNumber(x, y, destination); 1512TensorPrimitives.MaxNumber(x, y, destination); 1529destination = TensorPrimitives.Min(x); 1539TensorPrimitives.Min(x, y, destination); 1549TensorPrimitives.Min(x, y, destination); 1566destination = TensorPrimitives.MinMagnitude(x); 1576TensorPrimitives.MinMagnitude(x, y, destination); 1586TensorPrimitives.MinMagnitude(x, y, destination); 1603destination = TensorPrimitives.MinMagnitudeNumber(x); 1613TensorPrimitives.MinMagnitudeNumber(x, y, destination); 1623TensorPrimitives.MinMagnitudeNumber(x, y, destination); 1640destination = TensorPrimitives.MinNumber(x); 1650TensorPrimitives.MinNumber(x, y, destination); 1660TensorPrimitives.MinNumber(x, y, destination); 1676TensorPrimitives.Multiply(x, y, destination); 1686TensorPrimitives.Multiply(x, y, destination); 1701TensorPrimitives.Negate(x, destination); 1716TensorPrimitives.OnesComplement(x, destination); 1731TensorPrimitives.PopCount(x, destination); 1748TensorPrimitives.Pow(x, y, destination); 1758TensorPrimitives.Pow(x, y, destination); 1768TensorPrimitives.Pow(x, y, destination); 1783destination = TensorPrimitives.Product(x); 1798TensorPrimitives.RadiansToDegrees(x, destination); 1813TensorPrimitives.Reciprocal(x, destination); 1828TensorPrimitives.RootN(x, y, destination); 1842TensorPrimitives.RotateLeft(x, y, destination); 1856TensorPrimitives.RotateRight(x, y, destination); 1872TensorPrimitives.Round(x, destination); 1882TensorPrimitives.Round(x, y.Item1, y.Item2, destination); 1897TensorPrimitives.ShiftLeft(x, shiftAmount, destination); 1912TensorPrimitives.ShiftRightArithmetic(x, shiftAmount, destination); 1927TensorPrimitives.ShiftRightLogical(x, shiftAmount, destination); 1942TensorPrimitives.Sigmoid(x, destination); 1957TensorPrimitives.Sin(x, destination); 1972TensorPrimitives.Sinh(x, destination); 1987TensorPrimitives.SinPi(x, destination); 2039TensorPrimitives.Sqrt(x, destination); 2056TensorPrimitives.Subtract(x, y, destination); 2066TensorPrimitives.Subtract(x, y, destination); 2076TensorPrimitives.Subtract(x, y, destination); 2091destination += TensorPrimitives.Sum(x); 2157destination += TensorPrimitives.SumOfSquares(x); 2172TensorPrimitives.Tan(x, destination); 2187TensorPrimitives.Tanh(x, destination); 2202TensorPrimitives.TanPi(x, destination); 2217TensorPrimitives.TrailingZeroCount(x, destination); 2232TensorPrimitives.Truncate(x, destination); 2248TensorPrimitives.Xor(x, y, destination); 2258TensorPrimitives.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>;