Repository: systemml Updated Branches: refs/heads/master 608ac39c4 -> 1f5089110
[MINOR] Extended rewrite 'fuse datagen and binary' by div operations Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/e54ed714 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/e54ed714 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/e54ed714 Branch: refs/heads/master Commit: e54ed71479e30372b1f8b9f4283ba1d5d77f322a Parents: 608ac39 Author: Matthias Boehm <mboe...@gmail.com> Authored: Sun Jun 11 21:58:01 2017 -0700 Committer: Matthias Boehm <mboe...@gmail.com> Committed: Sun Jun 11 22:53:28 2017 -0700 ---------------------------------------------------------------------- .../RewriteAlgebraicSimplificationStatic.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/e54ed714/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 d6b4559..b8f9369 100644 --- a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java +++ b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java @@ -337,6 +337,7 @@ public class RewriteAlgebraicSimplificationStatic extends HopRewriteRule * @return high-level operator * @throws HopsException if HopsException occurs */ + @SuppressWarnings("incomplete-switch") private Hop fuseDatagenAndBinaryOperation( Hop hi ) throws HopsException { @@ -360,19 +361,20 @@ public class RewriteAlgebraicSimplificationStatic extends HopRewriteRule Hop max = left.getInput().get(params.get(DataExpression.RAND_MAX)); double sval = ((LiteralOp)right).getDoubleValue(); - if( (bop.getOp()==OpOp2.MULT || bop.getOp()==OpOp2.PLUS || bop.getOp() == OpOp2.MINUS) + if( HopRewriteUtils.isBinary(bop, OpOp2.MULT, OpOp2.PLUS, OpOp2.MINUS, OpOp2.DIV) && min instanceof LiteralOp && max instanceof LiteralOp && pdf instanceof LiteralOp && DataExpression.RAND_PDF_UNIFORM.equals(((LiteralOp)pdf).getStringValue()) ) { //create fused data gen operator DataGenOp gen = null; - if( bop.getOp()==OpOp2.MULT ) - gen = HopRewriteUtils.copyDataGenOp(inputGen, sval, 0); - else { //OpOp2.PLUS | OpOp2.MINUS - sval *= (bop.getOp()==OpOp2.MINUS) ? -1 : 1; - gen = HopRewriteUtils.copyDataGenOp(inputGen, 1, sval); + switch( bop.getOp() ) { //fuse via scale and shift + case MULT: gen = HopRewriteUtils.copyDataGenOp(inputGen, sval, 0); break; + case PLUS: + case MINUS: gen = HopRewriteUtils.copyDataGenOp(inputGen, + 1, sval * ((bop.getOp()==OpOp2.MINUS)?-1:1)); break; + case DIV: gen = HopRewriteUtils.copyDataGenOp(inputGen, 1/sval, 0); break; } - + //rewire all parents (avoid anomalies with replicated datagen) List<Hop> parents = new ArrayList<Hop>(bop.getParent()); for( Hop p : parents )