public void TestSparseMatrixMultiplication() { // https://en.wikipedia.org/wiki/Sparse_matrix var aDense = new float[] { 0, 0, 0, 0, 5, 8, 0, 0, 0, 0, 3, 0, 0, 6, 0, 0 }; var a = new float[] { 5, 8, 3, 6 }; var ja = new int[] { 0, 1, 2, 1 }; var ia = new int[] { 0, 0, 2, 3, 4 }; var bDense = new float[] { 1, 2, 0, 0, 0, 0, 0, 3, 0, 4, 0, 0, 0, 0, 5, 6, 7, 0, 0, 0, 0, 0, 0, 8, }; var cDense = new float[4 * 6]; var c = new float[4 * 6]; Provider.sgemm(Order.RowMajor, Transpose.NoTrans, Transpose.NoTrans, 4, 6, 4, 1, aDense, 0, 4, bDense, 0, 6, 0, cDense, 0, 6); Provider.scsrmm(Transpose.NoTrans, 4, 6, 4, 1, a, 0, ja, 0, ia, 0, bDense, 0, 6, 0, c, 0, 6); AssertArray.AreEqual(cDense, c); }
public static void gemm(Order Order, Transpose TransA, Transpose TransB, int M, int N, int K, float alpha, float[] A, int offseta, int lda, float[] B, int offsetb, int ldb, float beta, float[] C, int offsetc, int ldc) { Provider.sgemm(Order, TransA, TransB, M, N, K, alpha, A, offseta, lda, B, offsetb, ldb, beta, C, offsetc, ldc); }