You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2018/10/16 19:57:25 UTC
systemml git commit: [SYSTEMML-2468] Fix MNC sparsity estimator
integer overflows
Repository: systemml
Updated Branches:
refs/heads/master 95bf8cfe6 -> f1b9d1c08
[SYSTEMML-2468] Fix MNC sparsity estimator integer overflows
This patch fixes various cases of the MNC (matrix histogram) sparsity
estimator that ran into integer overflows on moderately large data.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/f1b9d1c0
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/f1b9d1c0
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/f1b9d1c0
Branch: refs/heads/master
Commit: f1b9d1c08d750059af7c4dad6938d80d4852ee86
Parents: 95bf8cf
Author: Matthias Boehm <mb...@gmail.com>
Authored: Tue Oct 16 21:48:38 2018 +0200
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Tue Oct 16 21:48:50 2018 +0200
----------------------------------------------------------------------
.../apache/sysml/hops/estim/EstimatorMatrixHistogram.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/systemml/blob/f1b9d1c0/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
index 206c6d5..52cca3d 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
@@ -152,19 +152,19 @@ public class EstimatorMatrixHistogram extends SparsityEstimator
//dot(h1.cNnz,h2rNnz) gives the exact number of non-zeros in the output
if( h1.rMaxNnz <= 1 || h2.cMaxNnz <= 1 ) {
for( int j=0; j<h1.getCols(); j++ )
- nnz += h1.cNnz[j] * h2.rNnz[j];
+ nnz += (long)h1.cNnz[j] * h2.rNnz[j];
}
//special case, with hybrid exact and approximate output
else if(h1.cNnz1e!=null && h2.rNnz1e != null) {
//note: normally h1.getRows()*h2.getCols() would define mnOut
//but by leveraging the knowledge of rows/cols w/ <=1 nnz, we account
//that exact and approximate fractions touch different areas
- long mnOut = (h1.rNonEmpty-h1.rN1) * (h2.cNonEmpty-h2.cN1);
+ long mnOut = (long)(h1.rNonEmpty-h1.rN1) * (h2.cNonEmpty-h2.cN1);
double spOutRest = 0;
for( int j=0; j<h1.getCols(); j++ ) {
//exact fractions, w/o double counting
- nnz += h1.cNnz1e[j] * h2.rNnz[j];
- nnz += (h1.cNnz[j]-h1.cNnz1e[j]) * h2.rNnz1e[j];
+ nnz += (long)h1.cNnz1e[j] * h2.rNnz[j];
+ nnz += (long)(h1.cNnz[j]-h1.cNnz1e[j]) * h2.rNnz1e[j];
//approximate fraction, w/o double counting
double lsp = (double)(h1.cNnz[j]-h1.cNnz1e[j])
* (h2.rNnz[j]-h2.rNnz1e[j]) / mnOut;
@@ -174,7 +174,7 @@ public class EstimatorMatrixHistogram extends SparsityEstimator
}
//general case with approximate output
else {
- long mnOut = h1.getRows()*h2.getCols();
+ long mnOut = (long)h1.getRows()*h2.getCols();
double spOut = 0;
for( int j=0; j<h1.getCols(); j++ ) {
double lsp = (double) h1.cNnz[j] * h2.rNnz[j] / mnOut;