Skip to content

Commit

Permalink
[SPARK-19759][ML] not using blas in ALSModel.predict for optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaido91 committed Nov 7, 2017
1 parent 4bacddb commit 8b0add6
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -289,9 +289,11 @@ class ALSModel private[ml] (

private val predict = udf { (featuresA: Seq[Float], featuresB: Seq[Float]) =>
if (featuresA != null && featuresB != null) {
// TODO(SPARK-19759): try dot-producting on Seqs or another non-converted type for
// potential optimization.
blas.sdot(rank, featuresA.toArray, 1, featuresB.toArray, 1)
var dotProduct = 0.0f
for(i <- 0 until rank) {
dotProduct += featuresA(i) * featuresB(i)
}
dotProduct
} else {
Float.NaN
}
Expand Down

0 comments on commit 8b0add6

Please sign in to comment.