Repository: systemml
Updated Branches:
  refs/heads/master 61925ab49 -> bb53c6b46


[MINOR] Fix parent-child link bug in Hop rewrite

The rewrite `fuseDatagenAndBinaryOperation3a` in
`RewriteAlgebraicSimplificationStatic` fails to change the parents when
rewiring DataGen Hops.  This patch adds the correct parents.
The problem arises in `LinearLogRegDMLTest` if the `ProgramRewriter`'s
`CHECK` flag is set to true (thereby invoking the HopDagValidator).

Closes #758.


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

Branch: refs/heads/master
Commit: bb53c6b4634f05cfa7f0c68ece45fd2f089d4634
Parents: 61925ab
Author: Dylan Hutchison <dhutc...@cs.washington.edu>
Authored: Sat Apr 14 16:23:10 2018 -0700
Committer: Matthias Boehm <mboe...@gmail.com>
Committed: Sat Apr 14 16:23:11 2018 -0700

----------------------------------------------------------------------
 src/main/java/org/apache/sysml/hops/DataGenOp.java           | 4 +++-
 .../hops/rewrite/RewriteAlgebraicSimplificationStatic.java   | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/bb53c6b4/src/main/java/org/apache/sysml/hops/DataGenOp.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/DataGenOp.java 
b/src/main/java/org/apache/sysml/hops/DataGenOp.java
index 3e271d5..0c6b586 100644
--- a/src/main/java/org/apache/sysml/hops/DataGenOp.java
+++ b/src/main/java/org/apache/sysml/hops/DataGenOp.java
@@ -374,8 +374,10 @@ public class DataGenOp extends Hop implements 
MultiThreadedHop
                return getInput().get(getParamIndex(key));
        }
        
-       public void setInput(String key, Hop hop) {
+       public void setInput(String key, Hop hop, boolean linkParent) {
                getInput().set(getParamIndex(key), hop);
+               if( linkParent )
+                       hop.getParent().add(this);
        }
 
        public boolean hasConstantValue() 

http://git-wip-us.apache.org/repos/asf/systemml/blob/bb53c6b4/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
index d1629ac..4eb223d 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
@@ -438,8 +438,8 @@ public class RewriteAlgebraicSimplificationStatic extends 
HopRewriteRule
                                        && 
HopRewriteUtils.isLiteralOfValue(min, 0)
                                        && 
HopRewriteUtils.isLiteralOfValue(max, 0) )
                                {
-                                       gen.setInput(DataExpression.RAND_MIN, 
right);
-                                       gen.setInput(DataExpression.RAND_MAX, 
right);
+                                       gen.setInput(DataExpression.RAND_MIN, 
right, true);
+                                       gen.setInput(DataExpression.RAND_MAX, 
right, true);
                                        //rewire all parents (avoid anomalies 
with replicated datagen)
                                        List<Hop> parents = new 
ArrayList<>(bop.getParent());
                                        for( Hop p : parents )
@@ -454,8 +454,8 @@ public class RewriteAlgebraicSimplificationStatic extends 
HopRewriteRule
                                        && 
HopRewriteUtils.isLiteralOfValue(max, 1) )
                                {
                                        if( 
HopRewriteUtils.isLiteralOfValue(min, 1) )
-                                               
gen.setInput(DataExpression.RAND_MIN, right);
-                                       gen.setInput(DataExpression.RAND_MAX, 
right);
+                                               
gen.setInput(DataExpression.RAND_MIN, right, true);
+                                       gen.setInput(DataExpression.RAND_MAX, 
right, true);
                                        //rewire all parents (avoid anomalies 
with replicated datagen)
                                        List<Hop> parents = new 
ArrayList<>(bop.getParent());
                                        for( Hop p : parents )

Reply via email to