Repository: systemml Updated Branches: refs/heads/branch-0.15 2811479c9 -> c4d777c51
[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/c4d777c5 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/c4d777c5 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/c4d777c5 Branch: refs/heads/branch-0.15 Commit: c4d777c51900ce1a36c891cb6848ed441a418fec Parents: 2811479 Author: Matthias Boehm <[email protected]> Authored: Thu Sep 7 18:03:52 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Thu Sep 7 18:03:52 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 | 8 ++++---- 4 files changed, 21 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/c4d777c5/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/c4d777c5/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/c4d777c5/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/c4d777c5/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..a33cdd4 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,7 +775,7 @@ 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)); + c[j] = vfun.execute(c[j], genexec(0, b, scalars, m, n, i, j)); count[aix[j]] ++; } //process current non-zero
