Skip to content

Commit bb93b9d

Browse files
committed
As aligned as possible (considering AVE and 512-bit instructions)
1 parent 4373659 commit bb93b9d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/Microsoft.ML.Tests/TrainerEstimators/MatrixFactorizationTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,17 +673,18 @@ public void InspectMatrixFactorizationModel()
673673

674674
// First copy the trained left factor matrix to an aligned for applying SSE code.
675675
var leftFactorMatrix = model.Model.LeftFactorMatrix;
676-
var leftFactorMatrixAligned = new AlignedArray(m * k, 16);
676+
var leftFactorMatrixAligned = new AlignedArray(m * k, 64);
677677
for (int i = 0; i < leftFactorMatrix.Count; ++i)
678678
leftFactorMatrixAligned[i] = leftFactorMatrix[i];
679679

680680
// Second copy the trained right factor row to a k-by-1 aligned vector for applying SSE code.
681-
var rightFactorVectorAligned = new AlignedArray(k, 16);
681+
var rightFactorVectorAligned = new AlignedArray(k, 64);
682682
for (int i = 0; i < k; ++i)
683683
rightFactorVectorAligned[i] = model.Model.RightFactorMatrix[1 * k + i]; // value at the i-th row and j-th column is indexed by i * k + j.
684684

685-
// Prepare buffer to store result.
686-
var valuesAtSecondColumn = new AlignedArray(m, 16);
685+
// Prepare buffer to store result. The result will be a matrix-vector product, where the matrix is leftFactorMatrix
686+
// and the vector is the 2nd row of rightFactorMatrix.
687+
var valuesAtSecondColumn = new AlignedArray(m, 64);
687688

688689
// Compute leftFactorMatrixAligned (m-by-k) * rightFactorVectorAligned (k-by-1).
689690
CpuMathUtils.MatrixTimesSource(false, leftFactorMatrixAligned, rightFactorVectorAligned, valuesAtSecondColumn, m);

0 commit comments

Comments
 (0)