138 references to CpuMathUtils
Microsoft.ML.CpuMath (5)
AlignedMatrix.cs (1)
556CpuMathUtils.ZeroMatrixItems(Items, ColCount, ColCountPhy, indices);
CpuAligenedMathUtils.cs (4)
22Contracts.Assert((mat.Items.CbAlign % CpuMathUtils.GetVectorAlignment()) == 0); 35Contracts.Assert((vec.Items.CbAlign % CpuMathUtils.GetVectorAlignment()) == 0); 91CpuMathUtils.MatrixTimesSource(colMajor, m.Items, A(src).Items, A(dst).Items, m.RunCnt); 106CpuMathUtils.MatrixTimesSource(!colMajor, m.Items, A(src).Items, A(dst).Items, m.RunCnt);
Microsoft.ML.CpuMath.PerformanceTests (22)
SmallInputCpuMathPerformanceTests.cs (22)
17=> CpuMathUtils.Add(DefaultScale, dst.AsSpan(0, arrayLength)); 21=> CpuMathUtils.Scale(DefaultScale, dst.AsSpan(0, arrayLength)); 25=> CpuMathUtils.Scale(DefaultScale, src, dst, arrayLength); 29=> CpuMathUtils.ScaleAdd(DefaultScale, DefaultScale, dst.AsSpan(0, arrayLength)); 33=> CpuMathUtils.AddScale(DefaultScale, src, dst, arrayLength); 37=> CpuMathUtils.AddScale(DefaultScale, src, idx, dst, arrayLength); 41=> CpuMathUtils.AddScaleCopy(DefaultScale, src, dst, result, arrayLength); 45=> CpuMathUtils.Add(src, dst, arrayLength); 49=> CpuMathUtils.Add(src, idx, dst, arrayLength); 53=> CpuMathUtils.MulElementWise(src1, src2, dst, arrayLength); 57=> CpuMathUtils.Sum(new Span<float>(src, 0, arrayLength)); 61=> CpuMathUtils.SumSq(new Span<float>(src, 0, arrayLength)); 65=> CpuMathUtils.SumSq(DefaultScale, src.AsSpan(0, arrayLength)); 69=> CpuMathUtils.SumAbs(src.AsSpan(0, arrayLength)); 73=> CpuMathUtils.SumAbs(DefaultScale, src.AsSpan(0, arrayLength)); 77=> CpuMathUtils.MaxAbs(src.AsSpan(0, arrayLength)); 81=> CpuMathUtils.MaxAbsDiff(DefaultScale, src.AsSpan(0, arrayLength)); 85=> CpuMathUtils.DotProductDense(src, dst, arrayLength); 89=> CpuMathUtils.DotProductSparse(src, dst, idx, arrayLength); 93=> CpuMathUtils.L2DistSquared(src, dst, arrayLength); 97=> CpuMathUtils.SdcaL1UpdateDense(DefaultScale, arrayLength, src, DefaultScale, dst, result); 101=> CpuMathUtils.SdcaL1UpdateSparse(DefaultScale, arrayLength, src, idx, DefaultScale, dst, result);
Microsoft.ML.CpuMath.UnitTests (28)
UnitTests.cs (28)
27private static readonly int _vectorAlignment = CpuMathUtils.GetVectorAlignment(); 260CpuMathUtils.MatrixTimesSource(false, mat, src, dst, dst.Size); 294CpuMathUtils.MatrixTimesSource(true, mat, src, dst, src.Size); 330CpuMathUtils.MatrixTimesSource(mat, idx, src, 0, 0, limit, dst, dst.Size); 359CpuMathUtils.Add(defaultScale, dst); 385CpuMathUtils.Scale(defaultScale, dst); 412CpuMathUtils.Scale(defaultScale, src, dst, dst.Length); 438CpuMathUtils.ScaleAdd(defaultScale, defaultScale, dst); 466CpuMathUtils.AddScale(defaultScale, src, dst, dst.Length); 490CpuMathUtils.AddScale(defaultScale, src, idx, dst, limit); 523CpuMathUtils.AddScaleCopy(defaultScale, src, dst, result, dst.Length); 555CpuMathUtils.Add(src, dst, dst.Length); 585CpuMathUtils.Add(src, idx, dst, limit); 619CpuMathUtils.MulElementWise(src1, src2, dst, dst.Length); 643var actual = CpuMathUtils.Sum(src); 666var actual = CpuMathUtils.SumSq(src); 684var actual = CpuMathUtils.SumSq(defaultScale, src); 714var actual = CpuMathUtils.SumAbs(src); 732var actual = CpuMathUtils.SumAbs(defaultScale, src); 756var actual = CpuMathUtils.MaxAbs(src); 785var actual = CpuMathUtils.MaxAbsDiff(defaultScale, src); 825var actual = CpuMathUtils.DotProductDense(src, dst, dst.Length); 859var actual = CpuMathUtils.DotProductSparse(src, dst, idx, limit); 891var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length); 905CpuMathUtils.ZeroMatrixItems(src, src.Size, src.Size, idx); 919CpuMathUtils.ZeroMatrixItems(src, src.Size / 2 - 1, src.Size / 2, idx); 947CpuMathUtils.SdcaL1UpdateDense(defaultScale, src.Length, src, defaultScale, v, w); 980CpuMathUtils.SdcaL1UpdateSparse(defaultScale, limit, src, idx, defaultScale, v, w);
Microsoft.ML.Data (36)
Deprecated\Vector\VBufferMathUtils.cs (15)
24return CpuMathUtils.SumSq(aValues); 32return CpuMathUtils.SumSq(a); 53return CpuMathUtils.SumAbs(aValues); 65return CpuMathUtils.MaxAbs(aValues); 76return CpuMathUtils.Sum(aValues); 90CpuMathUtils.Scale(c, editor.Values); 121CpuMathUtils.Scale(c, srcValues, editor.Values, length); 131CpuMathUtils.Scale(c, srcValues, editor.Values, count); 151CpuMathUtils.Add(srcValues, editor.Values, src.Length); 153CpuMathUtils.Add(srcValues, src.GetIndices(), editor.Values, srcValues.Length); 179CpuMathUtils.AddScale(c, srcValues, editor.Values, src.Length); 181CpuMathUtils.AddScale(c, srcValues, src.GetIndices(), editor.Values, srcValues.Length); 209CpuMathUtils.AddScaleCopy(c, srcValues, dst.GetValues(), editor.Values, length); 256CpuMathUtils.AddScale(c, srcValues, values, srcValues.Length); 258CpuMathUtils.AddScale(c, srcValues, src.GetIndices(), values, srcValues.Length);
Deprecated\Vector\VectorUtils.cs (21)
27return CpuMathUtils.DotProductDense(a, b, a.Length); 37return CpuMathUtils.DotProductDense(a, bValues, b.Length); 38return CpuMathUtils.DotProductSparse(a, bValues, b.GetIndices(), bValues.Length); 53return CpuMathUtils.DotProductDense(aValues, bValues, a.Length); 54return CpuMathUtils.DotProductSparse(aValues, bValues, b.GetIndices(), bValues.Length); 58return CpuMathUtils.DotProductSparse(bValues, aValues, a.GetIndices(), aValues.Length); 167CpuMathUtils.MulElementWise(a.GetValues(), dst.GetValues(), editor.Values, a.Length); 224var normA = CpuMathUtils.SumSq(valuesA); 227var normB = CpuMathUtils.SumSq(valuesB); 228var dotP = CpuMathUtils.DotProductSparse(valuesA, valuesB, indicesB, valuesB.Length); 240return CpuMathUtils.L2DistSquared(valuesA, valuesB, length); 263return CpuMathUtils.DotProductDense(aValues.Slice(offset), bValues, b.Length); 264return CpuMathUtils.DotProductSparse(aValues.Slice(offset), bValues, b.GetIndices(), bValues.Length); 313return CpuMathUtils.DotProductDense(a.AsSpan(offset), bValues, b.Length); 314return CpuMathUtils.DotProductSparse(a.AsSpan(offset), bValues, b.GetIndices(), bValues.Length); 433CpuMathUtils.Add(src, dst, src.Length); 451CpuMathUtils.AddScale(c, srcValues, dst, srcValues.Length); 504CpuMathUtils.AddScale(c, src, dst, src.Length); 512return MathUtils.Sqrt(CpuMathUtils.SumSq(a)); 522return CpuMathUtils.Sum(a); 536CpuMathUtils.Scale(c, dst);
Microsoft.ML.KMeansClustering (1)
KMeansPlusPlusTrainer.cs (1)
934CpuMathUtils.Add(workStateWeights[i], weights, totalSamples);
Microsoft.ML.Mkl.Components (2)
VectorWhitening.cs (2)
702editor.Values[i] = CpuMathUtils.DotProductSparse(model.AsSpan(offs), values, indices, count); 712return CpuMathUtils.DotProductSparse(a.AsSpan(aOffset), b, indices, count);
Microsoft.ML.StandardTrainers (6)
Standard\SdcaBinary.cs (2)
880CpuMathUtils.SdcaL1UpdateDense(primalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 882CpuMathUtils.SdcaL1UpdateSparse(primalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values);
Standard\SdcaMulticlass.cs (4)
298CpuMathUtils.SdcaL1UpdateDense(-primalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 300CpuMathUtils.SdcaL1UpdateSparse(-primalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 329CpuMathUtils.SdcaL1UpdateDense(labelPrimalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 331CpuMathUtils.SdcaL1UpdateSparse(labelPrimalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values);
Microsoft.ML.Tests (1)
TrainerEstimators\MatrixFactorizationTests.cs (1)
841CpuMathUtils.MatrixTimesSource(false, leftFactorMatrixAligned, rightFactorVectorAligned, valuesAtSecondColumn, m);
Microsoft.ML.TimeSeries (16)
AdaptiveSingularSpectrumSequenceModeler.cs (16)
272_x = new CpuAlignedVector(windowSize, CpuMathUtils.GetVectorAlignment()); 273_xSmooth = new CpuAlignedVector(windowSize, CpuMathUtils.GetVectorAlignment()); 327_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 328_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 332_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment()); 333_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment()); 434_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment()); 439_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment()); 444_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 445_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 1112_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment()); 1113_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment()); 1294_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 1295_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment()); 1332_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment()); 1335_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment());
Microsoft.ML.Transforms (21)
GcnTransform.cs (10)
506CpuMathUtils.Scale(normScale, src.GetValues(), dstValues, count); 517CpuMathUtils.ScaleAdd(normScale, -offset, editor.Values); 519CpuMathUtils.Add(-offset, editor.Values); 533var tmpMean = CpuMathUtils.Sum(values) / length; 541sumSq += CpuMathUtils.SumSq(tmpMean, values); 561sumSq += CpuMathUtils.SumSq(mean, values); 573return MathUtils.Sqrt(CpuMathUtils.SumSq(mean, values)); 584return CpuMathUtils.SumAbs(mean, values); 595return CpuMathUtils.MaxAbsDiff(mean, values); 602return CpuMathUtils.Sum(src) / length;
RandomFourierFeaturizing.cs (11)
124RndFourierVectors = new AlignedArray(roundedUpD * roundedUpNumFeatures, CpuMathUtils.GetVectorAlignment()); 125RotationTerms = _useSin ? null : new AlignedArray(roundedUpD, CpuMathUtils.GetVectorAlignment()); 158RndFourierVectors = new AlignedArray(roundedUpD * roundedUpNumFeatures, CpuMathUtils.GetVectorAlignment()); 159RotationTerms = _useSin ? null : new AlignedArray(roundedUpD, CpuMathUtils.GetVectorAlignment()); 227private static readonly int _cfltAlign = CpuMathUtils.GetVectorAlignment() / sizeof(float); 517var featuresAligned = new AlignedArray(RoundUp(_srcTypes[iinfo].GetValueCount(), _cfltAlign), CpuMathUtils.GetVectorAlignment()); 518var productAligned = new AlignedArray(RoundUp(_parent._transformInfos[iinfo].NewDim, _cfltAlign), CpuMathUtils.GetVectorAlignment()); 534var featuresAligned = new AlignedArray(RoundUp(1, _cfltAlign), CpuMathUtils.GetVectorAlignment()); 535var productAligned = new AlignedArray(RoundUp(_parent._transformInfos[iinfo].NewDim, _cfltAlign), CpuMathUtils.GetVectorAlignment()); 569CpuMathUtils.MatrixTimesSource(false, transformInfo.RndFourierVectors, featuresAligned, productAligned, 579CpuMathUtils.MatrixTimesSource(transformInfo.RndFourierVectors, srcIndices, featuresAligned, 0, 0,