Repository: systemml
Updated Branches:
  refs/heads/master 430c04d59 -> 5dee6c7ed


[SYSTEMML-2468] Extended MNC sketch propagation (track full diags)

Closes #810.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/5dee6c7e
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/5dee6c7e
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/5dee6c7e

Branch: refs/heads/master
Commit: 5dee6c7edd8b43e14ce1ee280863df5011a989cf
Parents: 430c04d
Author: Johanna Sommer <[email protected]>
Authored: Tue Jul 31 21:25:18 2018 -0700
Committer: Matthias Boehm <[email protected]>
Committed: Tue Jul 31 21:38:16 2018 -0700

----------------------------------------------------------------------
 .../sysml/hops/estim/EstimatorMatrixHistogram.java     | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/5dee6c7e/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 e00c005..b2aad66 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
@@ -149,11 +149,13 @@ public class EstimatorMatrixHistogram extends 
SparsityEstimator
                private final int rN1, cN1;             //number of rows/cols 
with nnz=1
                private final int rNonEmpty, cNonEmpty; //number of non-empty 
rows/cols (w/ empty is nnz=0)
                private final int rNdiv2, cNdiv2;       //number of rows/cols 
with nnz > #cols/2 and #rows/2
+               private boolean fullDiag;               //true if there exists 
a full diagonal of nonzeros
                
                public MatrixHistogram(MatrixBlock in, boolean useExcepts) {
                        // 1) allocate basic synopsis
                        rNnz = new int[in.getNumRows()];
                        cNnz = new int[in.getNumColumns()];
+                       fullDiag = in.getNumRows() == in.getNonZeros();
                        
                        // 2) compute basic synopsis details
                        if( !in.isEmpty() ) {
@@ -161,10 +163,12 @@ public class EstimatorMatrixHistogram extends 
SparsityEstimator
                                        SparseBlock sblock = 
in.getSparseBlock();
                                        for( int i=0; i<in.getNumRows(); i++ ) {
                                                if( sblock.isEmpty(i) ) 
continue;
+                                               int apos = sblock.pos(i);
                                                int alen = sblock.size(i);
+                                               int[] aix = sblock.indexes(i);
                                                rNnz[i] = alen;
-                                               
LibMatrixAgg.countAgg(sblock.values(i),
-                                                       cNnz, 
sblock.indexes(i), sblock.pos(i), alen);
+                                               
LibMatrixAgg.countAgg(sblock.values(i), cNnz, aix, apos, alen);
+                                               fullDiag &= aix[apos] == i;
                                        }
                                }
                                else {
@@ -174,6 +178,7 @@ public class EstimatorMatrixHistogram extends 
SparsityEstimator
                                                int lnnz = 0, aix = 
dblock.pos(i);
                                                for( int j=0; 
j<in.getNumColumns(); j++ ) {
                                                        if( avals[aix+j] != 0 ) 
{
+                                                               fullDiag &= (i 
== j);
                                                                cNnz[j] ++;
                                                                lnnz ++;
                                                        }
@@ -250,6 +255,10 @@ public class EstimatorMatrixHistogram extends 
SparsityEstimator
                }
                
                public static MatrixHistogram 
deriveOutputHistogram(MatrixHistogram h1, MatrixHistogram h2, double spOut) {
+                       //exact propagation if lhs or rhs full diag
+                       if( h1.fullDiag ) return h2;
+                       if( h2.fullDiag ) return h1;
+                       
                        //get input/output nnz for scaling
                        long nnz1 = Arrays.stream(h1.rNnz).sum();
                        long nnz2 = Arrays.stream(h2.cNnz).sum();

Reply via email to