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/26 19:20:20 UTC

systemml git commit: [MINOR] Improved MNC estimator for chains of matrix operations

Repository: systemml
Updated Branches:
  refs/heads/master d9d6f5615 -> 5de683daa


[MINOR] Improved MNC estimator for chains of matrix operations

This patch makes a minor improvement to the MNC sparsity estimator. We
now propagate rNonEmpty and cNonEmpty on sketch propagation and use this
information in the generic fallback estimation path. Exploiting the
structure of empty rows and columns helps in adjusting the expected
collisions via the known output area.


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

Branch: refs/heads/master
Commit: 5de683daac87e681f2b9eaf6dec3cc5d7062124d
Parents: d9d6f56
Author: Matthias Boehm <mb...@gmail.com>
Authored: Fri Oct 26 19:41:17 2018 +0200
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Fri Oct 26 19:58:19 2018 +0200

----------------------------------------------------------------------
 .../org/apache/sysml/hops/estim/EstimatorDensityMap.java    | 2 +-
 .../apache/sysml/hops/estim/EstimatorMatrixHistogram.java   | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/5de683da/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
index e513937..260df5d 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
@@ -101,7 +101,7 @@ public class EstimatorDensityMap extends SparsityEstimator
 	 * @param m2Map density map right-hand-side operand
 	 * @return density map
 	 */
-	private DensityMap estimIntern(DensityMap m1Map, DensityMap m2Map, OpCode op) {
+	public DensityMap estimIntern(DensityMap m1Map, DensityMap m2Map, OpCode op) {
 		switch(op) {
 			case MM:      return estimInternMM(m1Map, m2Map);
 			case MULT:    return estimInternMult(m1Map, m2Map);

http://git-wip-us.apache.org/repos/asf/systemml/blob/5de683da/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 22ff341..088d51c 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorMatrixHistogram.java
@@ -110,7 +110,7 @@ public class EstimatorMatrixHistogram extends SparsityEstimator
 		return estimIntern(h1, null, op, null);
 	}
 	
-	private double estimIntern(MatrixHistogram h1, MatrixHistogram h2, OpCode op, long[] misc) {
+	public double estimIntern(MatrixHistogram h1, MatrixHistogram h2, OpCode op, long[] misc) {
 		double msize = (double)h1.getRows()*h1.getCols();
 		switch (op) {
 			case MM:
@@ -184,7 +184,7 @@ public class EstimatorMatrixHistogram extends SparsityEstimator
 		}
 		//general case with approximate output
 		else {
-			long mnOut = (long)h1.getRows()*h2.getCols();
+			long mnOut = (long)h1.rNonEmpty*h2.cNonEmpty;
 			double spOut = 0;
 			for( int j=0; j<h1.getCols(); j++ ) {
 				double lsp = (double) h1.cNnz[j] * h2.rNnz[j] / mnOut;
@@ -312,8 +312,11 @@ public class EstimatorMatrixHistogram extends SparsityEstimator
 			rMaxNnz = rmax;
 			cMaxNnz = cmax;
 			rN1 = cN1 = -1;
-			rNonEmpty = cNonEmpty = -1;
 			rNdiv2 = cNdiv2 = -1;
+			
+			//update non-zero rows/cols
+			rNonEmpty = (int)Arrays.stream(rNnz).filter(i -> i!=0).count();
+			cNonEmpty = (int)Arrays.stream(cNnz).filter(i -> i!=0).count();
 		}
 		
 		public int getRows() {