Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-11826][MLlib] Refactor add() and subtract() methods #9916

Closed
wants to merge 6 commits into from

Conversation

ehsanmok
Copy link
Contributor

@srowen Could you please check this when you have time?

@SparkQA
Copy link

SparkQA commented Nov 23, 2015

Test build #46551 has finished for PR 9916 at commit 3b35af2.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 25, 2015

Test build #46644 has finished for PR 9916 at commit 5e9f012.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Nov 27, 2015

I'd defer to @mengxr on this one for final approval but yes that's definitely what I had in mind. It's nice that you refactored add and subtract together

@ehsanmok ehsanmok changed the title [SPARK-11826][MLlib] Reimplement add() and subtract() methods [SPARK-11826][MLlib] Refactor add() and subtract() methods Dec 7, 2015
@ehsanmok
Copy link
Contributor Author

ehsanmok commented Dec 8, 2015

@mengxr Could you please check this?
Thanks

@ehsanmok
Copy link
Contributor Author

ehsanmok commented Jan 7, 2016

@mengxr @srowen @jkbradley Why reviewing this simple thing which is important for my application is taking so long?

@jkbradley
Copy link
Member

@ehsanmok Apologies for the slow review. We do constantly have ~100 pending PRs and many more JIRAs, so they can be hard to cover with limited reviewer bandwidth.

I'll take a look now.

@ehsanmok
Copy link
Contributor Author

ehsanmok commented Jan 8, 2016

@jkbradley thank you! I'm guess that'd be suitable for Spark 1.6.1 so Since annotations should be updated, right?

* if it is being added to a [[DenseMatrix]]. If two dense matrices are added, the output will
* also be a [[DenseMatrix]].
* For given matrices `this` and `other` of compatible dimensions and compatible block dimensions,
* it applies an associative binary function on their corresponding blocks.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not associative (subtraction is not)

@SparkQA
Copy link

SparkQA commented Jan 15, 2016

Test build #49436 has finished for PR 9916 at commit 7ca9036.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 15, 2016

Test build #49439 has finished for PR 9916 at commit e32cd4f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ehsanmok
Copy link
Contributor Author

@jkbradley Thank you for your instructive and detailed feedbacks. It should be fine now. Please review it.

.map { case ((blockRowIndex, blockColIndex), (a, b)) =>
if (a.size > 1 || b.size > 1) {
throw new SparkException("There are multiple MatrixBlocks with indices: " +
s"($blockRowIndex, $blockColIndex). Please remove them.")
}
if (a.isEmpty) {
new MatrixBlock((blockRowIndex, blockColIndex), b.head)
val zeroBlock = BM.zeros[Double](b.head.numRows, b.head.numCols)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making an explicit matrix of all 0s. It would be better to create a sparse matrix of all zeros to avoid the memory allocation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have said use CSCMatrix.zeros(rows, cols). What do you mean by "then would have to add every zero for later operations?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem now is that; there's no implicits for adding and subtracting CSCMatrix and BM! So should I leave that as is then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkbradley so I'll modify the doc (as mentioned below) and commit. I don't think there's a better option available for zero sparse matrices!

@SparkQA
Copy link

SparkQA commented Jan 21, 2016

Test build #49893 has finished for PR 9916 at commit 4353e02.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ehsanmok
Copy link
Contributor Author

@jkbradley could you please check the update soon?

@jkbradley
Copy link
Member

@ehsanmok Sorry for the delay. Could you please add a to-do in the code for using zero matrices more efficiently? Other than that, it looks fine.

Would you be interested in submitting a PR to Breeze to add a primitive for subtracting a DenseMatrix and CSCMatrix? If you can, please CC me on the PR, and I can help review it. Thanks!

@ehsanmok
Copy link
Contributor Author

ehsanmok commented Mar 1, 2016

@jkbradley I'd really like to but don't have enough time these days. I'll add that to my to-do list and will let you know then.

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52263 has finished for PR 9916 at commit ef176e6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ehsanmok
Copy link
Contributor Author

ehsanmok commented Mar 3, 2016

@jkbradley I hope it doesn't take another month waiting to get merged!

@jkbradley
Copy link
Member

Yes, I was checking about whether it'd be OK to merge with this less efficient implementation. I think so, though, so I'll go ahead and merge it after re-running fresh tests.

@SparkQA
Copy link

SparkQA commented Mar 9, 2016

Test build #2623 has finished for PR 9916 at commit ef176e6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 15, 2016

Test build #2640 has finished for PR 9916 at commit ef176e6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jkbradley
Copy link
Member

Merging with master

@asfgit asfgit closed this in 992142b Mar 15, 2016
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
srowen Could you please check this when you have time?

Author: Ehsan M.Kermani <ehsanmo1367@gmail.com>

Closes apache#9916 from ehsanmok/JIRA-11826.
@ehsanmok ehsanmok deleted the JIRA-11826 branch June 15, 2016 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants