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/11/22 07:07:05 UTC

[2/2] systemml git commit: [SYSTEMML-2028] Fix codegen invalid fallback from row to cell ops

[SYSTEMML-2028] Fix codegen invalid fallback from row to cell ops

This patch fixes issues of perftest Mlogreg 10M x 1K, icpt1 with codegen
due to unsupported cbind operations in cell templates. The root cause
was a violated block size constraint which led to an invalid fallback
from row to cell operations although these are not supported for cell
templates. With this patch, the fallback happens in an operator aware
manner, removing the entry in case of invalid fallbacks.


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

Branch: refs/heads/master
Commit: 5b9c12df62951a49179b39b05bb774da97d3cd37
Parents: 7339499
Author: Matthias Boehm <mb...@gmail.com>
Authored: Tue Nov 21 22:02:07 2017 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Tue Nov 21 22:02:07 2017 -0800

----------------------------------------------------------------------
 .../opt/PlanSelectionFuseCostBasedV2.java       | 37 +++++++++++++-------
 1 file changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/5b9c12df/src/main/java/org/apache/sysml/hops/codegen/opt/PlanSelectionFuseCostBasedV2.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/opt/PlanSelectionFuseCostBasedV2.java b/src/main/java/org/apache/sysml/hops/codegen/opt/PlanSelectionFuseCostBasedV2.java
index 7ad00fa..00b1543 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/opt/PlanSelectionFuseCostBasedV2.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/opt/PlanSelectionFuseCostBasedV2.java
@@ -639,6 +639,11 @@ public class PlanSelectionFuseCostBasedV2 extends PlanSelection
 			|| HopRewriteUtils.isBinary(hop, OpOp2.CBIND));
 	}
 	
+	private static boolean isValidRow2CellOp(Hop hop) {
+		return !(HopRewriteUtils.isBinary(hop, OpOp2.CBIND)
+			|| (hop instanceof AggBinaryOp && hop.getDim1()!=1 && hop.getDim2()!=1));
+	}
+	
 	private static void pruneInvalidAndSpecialCasePlans(CPlanMemoTable memo, PlanPartition part) 
 	{	
 		//prune invalid row entries w/ violated blocksize constraint
@@ -744,24 +749,30 @@ public class PlanSelectionFuseCostBasedV2 extends PlanSelection
 		//i.e., plans that become invalid after the previous pruning step
 		long hopID = current.getHopID();
 		if( part.getPartition().contains(hopID) && memo.contains(hopID, TemplateType.ROW) ) {
-			for( MemoTableEntry me : memo.get(hopID, TemplateType.ROW) ) {
+			Iterator<MemoTableEntry> iter = memo.get(hopID, TemplateType.ROW).iterator();
+			while( iter.hasNext() ) {
+				MemoTableEntry me = iter.next();
 				//convert leaf node with pure vector inputs
-				if( !me.hasPlanRef() && !TemplateUtils.hasMatrixInput(current) ) {
-					me.type = TemplateType.CELL;
-					if( LOG.isTraceEnabled() )
-						LOG.trace("Converted leaf memo table entry from row to cell: "+me);
-				}
+				boolean applyLeaf = (!me.hasPlanRef() 
+					&& !TemplateUtils.hasMatrixInput(current));
 				
 				//convert inner node without row template input
-				if( me.hasPlanRef() && !ROW_TPL.open(current) ) {
-					boolean hasRowInput = false;
-					for( int i=0; i<3; i++ )
-						if( me.isPlanRef(i) )
-							hasRowInput |= memo.contains(me.input(i), TemplateType.ROW);
-					if( !hasRowInput ) {
+				boolean applyInner = !applyLeaf && !ROW_TPL.open(current);
+				for( int i=0; i<3 & applyInner; i++ )
+					if( me.isPlanRef(i) )
+						applyInner &= !memo.contains(me.input(i), TemplateType.ROW);
+				
+				if( applyLeaf || applyInner ) {
+					String type = applyLeaf ? "leaf" : "inner";
+					if( isValidRow2CellOp(current) ) {
 						me.type = TemplateType.CELL;
 						if( LOG.isTraceEnabled() )
-							LOG.trace("Converted inner memo table entry from row to cell: "+me);	
+							LOG.trace("Converted "+type+" memo table entry from row to cell: "+me);
+					}
+					else {
+						if( LOG.isTraceEnabled() )
+							LOG.trace("Removed "+type+" memo table entry row (unsupported cell): "+me);
+						iter.remove();
 					}
 				}
 			}