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 2017/09/08 00:57:33 UTC

systemml git commit: [SYSTEMML-1897] Fix codegen cell cplan construction and unsafe colaggs

Repository: systemml
Updated Branches:
  refs/heads/master 824e4c05c -> 722c8f155


[SYSTEMML-1897] Fix codegen cell cplan construction and unsafe colaggs

This patch fixes the codegen cplan construction of cell templates for
special cases with transpose operations over intermediates. We now flip
row and column lookups accordingly in order to support all scenarios of
matrix-vector operations. Note that this patch fixes perftest issues of
multinomial mlogreg and naive bayes over both dense and sparse data.

Furthermore, this patch also fixes runtime issues of the cell operator
skeleton of sparse-unsafe column aggregations over sparse data.
column aggregations.

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

Branch: refs/heads/master
Commit: 722c8f155c6d89246de06b24444c6f08cf58dc64
Parents: 824e4c0
Author: Matthias Boehm <mb...@gmail.com>
Authored: Thu Sep 7 17:04:24 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Thu Sep 7 17:57:25 2017 -0700

----------------------------------------------------------------------
 .../apache/sysml/hops/codegen/template/TemplateCell.java |  4 ++++
 .../sysml/hops/codegen/template/TemplateUtils.java       | 11 +++++++++++
 .../org/apache/sysml/hops/rewrite/HopRewriteUtils.java   |  5 ++---
 .../org/apache/sysml/runtime/codegen/SpoofCellwise.java  | 10 +++++-----
 4 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/722c8f15/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java
index b7e2a2d..9d0c7b5 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java
@@ -241,6 +241,10 @@ public class TemplateCell extends TemplateBase
 		{
 			out = TemplateUtils.skipTranspose(tmp.get(hop.getHopID()), 
 				hop, tmp, compileLiterals);
+			//correct indexing types of existing lookups
+			if( !HopRewriteUtils.containsOp(hop.getParent(), AggBinaryOp.class) )
+				TemplateUtils.rFlipVectorLookups(out);
+			//maintain input hops
 			if( out instanceof CNodeData && !inHops.contains(hop.getInput().get(0)) )
 				inHops.add(hop.getInput().get(0));
 		}

http://git-wip-us.apache.org/repos/asf/systemml/blob/722c8f15/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
index ecfe7d5..ec7bf19 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
@@ -448,4 +448,15 @@ public class TemplateUtils
 		current.setVisited();
 		return ret;
 	}
+	
+	public static void rFlipVectorLookups(CNode current) {
+		//flip vector lookups if necessary
+		if( isUnary(current, UnaryType.LOOKUP_C) )
+			((CNodeUnary)current).setType(UnaryType.LOOKUP_R);
+		else if( isUnary(current, UnaryType.LOOKUP_R) )
+			((CNodeUnary)current).setType(UnaryType.LOOKUP_C);
+		//recursively process children
+		for( CNode input : current.getInput() )
+			rFlipVectorLookups(input);
+	}
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/722c8f15/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
index dcc740e..2f4c994 100644
--- a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
+++ b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
@@ -31,7 +31,6 @@ import org.apache.sysml.hops.AggBinaryOp;
 import org.apache.sysml.hops.AggUnaryOp;
 import org.apache.sysml.hops.BinaryOp;
 import org.apache.sysml.hops.DataOp;
-import org.apache.sysml.hops.FunctionOp;
 import org.apache.sysml.hops.Hop;
 import org.apache.sysml.hops.Hop.AggOp;
 import org.apache.sysml.hops.Hop.DataGenMethod;
@@ -1047,10 +1046,10 @@ public class HopRewriteUtils
 			 && ((DataOp)hop).getInputFormatType()!=FileFormatTypes.BINARY);
 	}
 	
-	public static boolean containsFunctioOp(ArrayList<Hop> candidates) {
+	public static boolean containsOp(ArrayList<Hop> candidates, Class<? extends Hop> clazz) {
 		if( candidates != null )
 			for( Hop cand : candidates )
-				if( cand instanceof FunctionOp )
+				if( cand.getClass().equals(clazz) )
 					return true;
 		return false;
 	}

http://git-wip-us.apache.org/repos/asf/systemml/blob/722c8f15/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
index 43a53bf..5f937f6 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
@@ -726,10 +726,10 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 					//process zeros before current non-zero
 					if( !sparseSafe )
 						for(int j=lastj+1; j<aix[k]; j++) {
-							kbuff.set(c[aix[j]], corr[aix[j]]);
+							kbuff.set(c[j], corr[j]);
 							kplus.execute2(kbuff, genexec(0, b, scalars, m, n, i, j));
-							c[aix[j]] = kbuff._sum;
-							corr[aix[j]] = kbuff._correction;
+							c[j] = kbuff._sum;
+							corr[j] = kbuff._correction;
 						}
 					//process current non-zero
 					lastj = aix[k];
@@ -775,8 +775,8 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 					//process zeros before current non-zero
 					if( !sparseSafe )
 						for(int j=lastj+1; j<aix[k]; j++) {
-							c[aix[j]] = vfun.execute(c[aix[j]], genexec(0, b, scalars, m, n, i, j));
-							count[aix[j]] ++;
+							c[j] = vfun.execute(c[j], genexec(0, b, scalars, m, n, i, j));
+							count[j] ++;
 						}
 					//process current non-zero
 					lastj = aix[k];