xuyang1706 commented on a change in pull request #9732: [FLINK-14153][ml] Add 
to BLAS a method that performs DenseMatrix and SparseVector multiplication.
URL: https://github.com/apache/flink/pull/9732#discussion_r336986540
 
 

 ##########
 File path: 
flink-ml-parent/flink-ml-lib/src/main/java/org/apache/flink/ml/common/linalg/BLAS.java
 ##########
 @@ -55,24 +78,34 @@ public static void axpy(double a, SparseVector x, 
DenseVector y) {
         * y += a * x .
         */
        public static void axpy(double a, DenseMatrix x, DenseMatrix y) {
-               assert x.m == y.m && x.n == y.n : "Matrix dimension 
mismatched.";
+               Preconditions.checkArgument(x.m == y.m && x.n == y.n, "Matrix 
dimension mismatched.");
                F2J_BLAS.daxpy(x.data.length, a, x.data, 1, y.data, 1);
        }
 
+       /**
+        * y[yOffset:yOffset+n] += a * x[xOffset:xOffset+n] .
+        */
+       public static void axpy(int n, double a, double[] x, int xOffset, 
double[] y, int yOffset) {
+               F2J_BLAS.daxpy(n, a, x, xOffset, 1, y, yOffset, 1);
 
 Review comment:
   Thanks, I have clarified in the inline doc that we should use F2J_BLAS for 
level-1 routines and NATIVE_BLAS for level-2 and level-3 routines. This is also 
the practices adopted by SparkML.
   
   The read from SPARK's mailing list you give here indeed shows the pitfalls 
when using NATIVE_BLAS. It makes clear that the underlying native BLAS libarary 
should not use multithreading. Fortunately, the default library uses a BLAS 
version provided by http://www.netlib.org, which is a single-threaded version. 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to