Repository: incubator-systemml Updated Branches: refs/heads/master 5412e2d75 -> 174bf7db2
[SYSTEMML-1467] Fix rewrite seq-table to rexpand (size awareness) This patch hardens the rewrite seq-table to rexpand for expressions like table(seq(1,nrow(v)), v, N, m) to account for scenarios where N != nrow(v). Furthermore, the rewrite has been moved accordingly from static to dynamic rewrites and there is a respective test suite for positive and negative patterns. Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/5937df93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/5937df93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/5937df93 Branch: refs/heads/master Commit: 5937df93e151a0f123c9f24393f7e3f8de0301f9 Parents: 5412e2d Author: Matthias Boehm <mboe...@gmail.com> Authored: Wed Apr 5 21:35:20 2017 -0700 Committer: Matthias Boehm <mboe...@gmail.com> Committed: Thu Apr 6 16:01:18 2017 -0700 ---------------------------------------------------------------------- .../sysml/hops/rewrite/HopRewriteUtils.java | 44 +++++-- .../RewriteAlgebraicSimplificationDynamic.java | 63 +++++++++ .../RewriteAlgebraicSimplificationStatic.java | 47 ------- .../misc/RewriteCTableToRExpandTest.java | 130 +++++++++++++++++++ .../misc/RewriteCTableToRExpandLeftNeg.dml | 27 ++++ .../misc/RewriteCTableToRExpandLeftPos.dml | 27 ++++ .../misc/RewriteCTableToRExpandRightNeg.dml | 27 ++++ .../misc/RewriteCTableToRExpandRightPos.dml | 27 ++++ .../functions/misc/ZPackageSuite.java | 1 + 9 files changed, 332 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/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 21a9acb..3857ca2 100644 --- a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java +++ b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java @@ -538,6 +538,15 @@ public class HopRewriteUtils return mmult; } + public static ParameterizedBuiltinOp createParameterizedBuiltinOp(Hop input, HashMap<String,Hop> args, ParamBuiltinOp op) { + ParameterizedBuiltinOp pbop = new ParameterizedBuiltinOp("tmp", DataType.MATRIX, ValueType.DOUBLE, op, args); + pbop.setOutputBlocksizes(input.getRowsInBlock(), input.getColsInBlock()); + copyLineNumbers(input, pbop); + pbop.refreshSizeInformation(); + + return pbop; + } + public static Hop createValueHop( Hop hop, boolean row ) throws HopsException { @@ -881,22 +890,29 @@ public class HopRewriteUtils || (hop.getInput().get(0).getDataType()==DataType.MATRIX && hop.getInput().get(1).getDataType()==DataType.SCALAR)); } - public static boolean isBasic1NSequence(Hop hop) - { - boolean ret = false; - - if( hop instanceof DataGenOp ) - { + public static boolean isBasic1NSequence(Hop hop) { + if( hop instanceof DataGenOp && ((DataGenOp)hop).getOp() == DataGenMethod.SEQ ) { DataGenOp dgop = (DataGenOp) hop; - if( dgop.getOp() == DataGenMethod.SEQ ){ - Hop from = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_FROM)); - Hop incr = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_INCR)); - ret = (from instanceof LiteralOp && getDoubleValueSafe((LiteralOp)from)==1) - &&(incr instanceof LiteralOp && getDoubleValueSafe((LiteralOp)incr)==1); - } + Hop from = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_FROM)); + Hop incr = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_INCR)); + return (from instanceof LiteralOp && getDoubleValueSafe((LiteralOp)from)==1) + &&(incr instanceof LiteralOp && getDoubleValueSafe((LiteralOp)incr)==1); } - - return ret; + return false; + } + + public static boolean isBasic1NSequence(Hop seq, Hop input, boolean row) { + if( seq instanceof DataGenOp && ((DataGenOp)seq).getOp() == DataGenMethod.SEQ ) { + DataGenOp dgop = (DataGenOp) seq; + Hop from = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_FROM)); + Hop to = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_TO)); + Hop incr = dgop.getInput().get(dgop.getParamIndex(Statement.SEQ_INCR)); + return isLiteralOfValue(from, 1) && isLiteralOfValue(incr, 1) + && (isLiteralOfValue(to, row?input.getDim1():input.getDim2()) + || (to instanceof UnaryOp && ((UnaryOp)to).getOp()==(row? + OpOp1.NROW:OpOp1.NCOL) && to.getInput().get(0)==input)); + } + return false; } public static boolean isBasicN1Sequence(Hop hop) http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java index d2e5831..74e832b 100644 --- a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java +++ b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java @@ -36,14 +36,17 @@ import org.apache.sysml.hops.Hop.Direction; import org.apache.sysml.hops.Hop.OpOp1; import org.apache.sysml.hops.Hop.OpOp3; import org.apache.sysml.hops.Hop.OpOp4; +import org.apache.sysml.hops.Hop.ParamBuiltinOp; import org.apache.sysml.hops.Hop.ReOrgOp; import org.apache.sysml.hops.HopsException; import org.apache.sysml.hops.IndexingOp; import org.apache.sysml.hops.LeftIndexingOp; import org.apache.sysml.hops.LiteralOp; import org.apache.sysml.hops.OptimizerUtils; +import org.apache.sysml.hops.ParameterizedBuiltinOp; import org.apache.sysml.hops.Hop.OpOp2; import org.apache.sysml.hops.ReorgOp; +import org.apache.sysml.hops.TernaryOp; import org.apache.sysml.hops.UnaryOp; import org.apache.sysml.lops.MapMultChain.ChainType; import org.apache.sysml.parser.DataExpression; @@ -190,6 +193,7 @@ public class RewriteAlgebraicSimplificationDynamic extends HopRewriteRule hi = simplifyScalarMVBinaryOperation(hi); //e.g., X*y -> X*as.scalar(y), if y is a 1-1 matrix hi = simplifyNnzComputation(hop, hi, i); //e.g., sum(ppred(X,0,"!=")) -> literal(nnz(X)), if nnz known hi = simplifyNrowNcolComputation(hop, hi, i); //e.g., nrow(X) -> literal(nrow(X)), if nrow known to remove data dependency + hi = simplifyTableSeqExpand(hop, hi, i); //e.g., table(seq(1,nrow(v)), v, nrow(v), m) -> rexpand(v, max=m, dir=row, ignore=false, cast=true) //process childs recursively after rewrites (to investigate pattern newly created by rewrites) if( !descendFirst ) @@ -2472,4 +2476,63 @@ public class RewriteAlgebraicSimplificationDynamic extends HopRewriteRule return hi; } + + private Hop simplifyTableSeqExpand(Hop parent, Hop hi, int pos) + throws HopsException + { + //pattern: table(seq(1,nrow(v)), v, nrow(v), m) -> rexpand(v, max=m, dir=row, ignore=false, cast=true) + //note: this rewrite supports both left/right sequence + if( hi instanceof TernaryOp && hi.getInput().size()==5 //table without weights + && HopRewriteUtils.isLiteralOfValue(hi.getInput().get(2), 1) //i.e., weight of 1 + && hi.getInput().get(3) instanceof LiteralOp && hi.getInput().get(4) instanceof LiteralOp) + { + Hop first = hi.getInput().get(0); + Hop second = hi.getInput().get(1); + + //pattern a: table(seq(1,nrow(v)), v, nrow(v), m, 1) + if( HopRewriteUtils.isBasic1NSequence(first, second, true) && second.dimsKnown() + && HopRewriteUtils.isLiteralOfValue(hi.getInput().get(3), second.getDim1()) ) + { + //setup input parameter hops + HashMap<String,Hop> args = new HashMap<String,Hop>(); + args.put("target", second); + args.put("max", hi.getInput().get(4)); + args.put("dir", new LiteralOp("cols")); + args.put("ignore", new LiteralOp(false)); + args.put("cast", new LiteralOp(true)); + + //create new hop + ParameterizedBuiltinOp pbop = HopRewriteUtils + .createParameterizedBuiltinOp(second, args, ParamBuiltinOp.REXPAND); + HopRewriteUtils.replaceChildReference(parent, hi, pbop, pos); + HopRewriteUtils.cleanupUnreferenced(hi); + hi = pbop; + + LOG.debug("Applied simplifyTableSeqExpand1 (line "+hi.getBeginLine()+")"); + } + //pattern b: table(v, seq(1,nrow(v)), m, nrow(v)) + else if( HopRewriteUtils.isBasic1NSequence(second, first, true) && first.dimsKnown() + && HopRewriteUtils.isLiteralOfValue(hi.getInput().get(4), first.getDim1()) ) + { + //setup input parameter hops + HashMap<String,Hop> args = new HashMap<String,Hop>(); + args.put("target", first); + args.put("max", hi.getInput().get(3)); + args.put("dir", new LiteralOp("rows")); + args.put("ignore", new LiteralOp(false)); + args.put("cast", new LiteralOp(true)); + + //create new hop + ParameterizedBuiltinOp pbop = HopRewriteUtils + .createParameterizedBuiltinOp(first, args, ParamBuiltinOp.REXPAND); + HopRewriteUtils.replaceChildReference(parent, hi, pbop, pos); + HopRewriteUtils.cleanupUnreferenced(hi); + hi = pbop; + + LOG.debug("Applied simplifyTableSeqExpand2 (line "+hi.getBeginLine()+")"); + } + } + + return hi; + } } http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/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 5c6b9c8..a3db317 100644 --- a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java +++ b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java @@ -170,7 +170,6 @@ public class RewriteAlgebraicSimplificationStatic extends HopRewriteRule hi = fuseLogNzBinaryOperation(hop, hi, i); //e.g., ppred(X,0,"!=")*log(X,0.5) -> log_nz(X,0.5) } hi = simplifyOuterSeqExpand(hop, hi, i); //e.g., outer(v, seq(1,m), "==") -> rexpand(v, max=m, dir=row, ignore=true, cast=false) - hi = simplifyTableSeqExpand(hop, hi, i); //e.g., table(seq(1,nrow(v)), v, nrow(v), m) -> rexpand(v, max=m, dir=row, ignore=false, cast=true) //hi = removeUnecessaryPPred(hop, hi, i); //e.g., ppred(X,X,"==")->matrix(1,rows=nrow(X),cols=ncol(X)) //process childs recursively after rewrites (to investigate pattern newly created by rewrites) @@ -1632,52 +1631,6 @@ public class RewriteAlgebraicSimplificationStatic extends HopRewriteRule return hi; } - private Hop simplifyTableSeqExpand(Hop parent, Hop hi, int pos) - throws HopsException - { - //pattern: table(seq(1,nrow(v)), v, nrow(v), m) -> rexpand(v, max=m, dir=row, ignore=false, cast=true) - //note: this rewrite supports both left/right sequence - - if( hi instanceof TernaryOp && hi.getInput().size()==5 //table without weights - && hi.getInput().get(2) instanceof LiteralOp - && HopRewriteUtils.getDoubleValue((LiteralOp)hi.getInput().get(2))==1 - && hi.getInput().get(3) instanceof LiteralOp && hi.getInput().get(4) instanceof LiteralOp) - { - if( (HopRewriteUtils.isBasic1NSequence(hi.getInput().get(0)) && - hi.getInput().get(4) instanceof LiteralOp) //pattern a: table(seq(1,nrow(v)), v, nrow(v), m) - ||(HopRewriteUtils.isBasic1NSequence(hi.getInput().get(1)) && - hi.getInput().get(3) instanceof LiteralOp) ) //pattern b: table(v, seq(1,nrow(v)), m, nrow(v)) - { - //determine variable parameters for pattern a/b - int ixTgt = HopRewriteUtils.isBasic1NSequence(hi.getInput().get(0)) ? 1 : 0; - int ixMax = HopRewriteUtils.isBasic1NSequence(hi.getInput().get(0)) ? 4 : 3; - String direction = HopRewriteUtils.isBasic1NSequence(hi.getInput().get(0)) ? "cols" : "rows"; - - //setup input parameter hops - HashMap<String,Hop> inputargs = new HashMap<String,Hop>(); - inputargs.put("target", hi.getInput().get(ixTgt)); - inputargs.put("max", hi.getInput().get(ixMax)); - inputargs.put("dir", new LiteralOp(direction)); - inputargs.put("ignore", new LiteralOp(false)); - inputargs.put("cast", new LiteralOp(true)); - - //create new hop - ParameterizedBuiltinOp pbop = new ParameterizedBuiltinOp("tmp", DataType.MATRIX, ValueType.DOUBLE, - ParamBuiltinOp.REXPAND, inputargs); - pbop.setOutputBlocksizes(hi.getRowsInBlock(), hi.getColsInBlock()); - pbop.refreshSizeInformation(); - - //relink new hop into original position - HopRewriteUtils.replaceChildReference(parent, hi, pbop, pos); - hi = pbop; - - LOG.debug("Applied simplifyTableSeqExpand (line "+hi.getBeginLine()+")"); - } - } - - return hi; - } - /** * NOTE: currently disabled since this rewrite is INVALID in the * presence of NaNs (because (NaN!=NaN) is true). http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteCTableToRExpandTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteCTableToRExpandTest.java b/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteCTableToRExpandTest.java new file mode 100644 index 0000000..aa7d25a --- /dev/null +++ b/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteCTableToRExpandTest.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.sysml.test.integration.functions.misc; + +import org.junit.Test; + +import org.junit.Assert; +import org.apache.sysml.runtime.matrix.MatrixCharacteristics; +import org.apache.sysml.test.integration.AutomatedTestBase; +import org.apache.sysml.test.integration.TestConfiguration; +import org.apache.sysml.test.utils.TestUtils; + +public class RewriteCTableToRExpandTest extends AutomatedTestBase +{ + private static final String TEST_NAME1 = "RewriteCTableToRExpandLeftPos"; + private static final String TEST_NAME2 = "RewriteCTableToRExpandRightPos"; + private static final String TEST_NAME3 = "RewriteCTableToRExpandLeftNeg"; + private static final String TEST_NAME4 = "RewriteCTableToRExpandRightNeg"; + + private static final String TEST_DIR = "functions/misc/"; + private static final String TEST_CLASS_DIR = TEST_DIR + RewriteCTableToRExpandTest.class.getSimpleName() + "/"; + + private static final int maxVal = 10; + private static final int rows = 123; + + private enum CropType { + CROP, + PAD + } + + @Override + public void setUp() { + TestUtils.clearAssertionInformation(); + addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "R" }) ); + addTestConfiguration( TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }) ); + addTestConfiguration( TEST_NAME3, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] { "R" }) ); + addTestConfiguration( TEST_NAME4, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] { "R" }) ); + } + + @Test + public void testRewriteCTableRExpandLeftPositiveDenseCrop() { + testRewriteCTableRExpand( TEST_NAME1, CropType.CROP ); + } + + @Test + public void testRewriteCTableRExpandLeftPositiveDensePad() { + testRewriteCTableRExpand( TEST_NAME1, CropType.PAD ); + } + + @Test + public void testRewriteCTableRExpandRightPositiveDenseCrop() { + testRewriteCTableRExpand( TEST_NAME2, CropType.CROP ); + } + + @Test + public void testRewriteCTableRExpandRightPositiveDensePad() { + testRewriteCTableRExpand( TEST_NAME2, CropType.PAD ); + } + + @Test + public void testRewriteCTableRExpandLeftNegativeDenseCrop() { + testRewriteCTableRExpand( TEST_NAME3, CropType.CROP ); + } + + @Test + public void testRewriteCTableRExpandLeftNegativeDensePad() { + testRewriteCTableRExpand( TEST_NAME3, CropType.PAD ); + } + + @Test + public void testRewriteCTableRExpandRightNegativeDenseCrop() { + testRewriteCTableRExpand( TEST_NAME4, CropType.CROP ); + } + + @Test + public void testRewriteCTableRExpandRightNegativeDensePad() { + testRewriteCTableRExpand( TEST_NAME4, CropType.PAD ); + } + + + private void testRewriteCTableRExpand( String testname, CropType type ) + { + TestConfiguration config = getTestConfiguration(testname); + loadTestConfiguration(config); + + int outDim = maxVal + ((type==CropType.CROP) ? -7 : 7); + + String HOME = SCRIPT_DIR + TEST_DIR; + fullDMLScriptName = HOME + testname + ".dml"; + programArgs = new String[]{ "-stats","-args", + input("A"), String.valueOf(outDim), output("R") }; + + fullRScriptName = HOME + testname + ".R"; + rCmd = getRCmd(inputDir(), String.valueOf(outDim), expectedDir()); + + double[][] A = getRandomMatrix(rows, 1, 1, 10, 1.0, 7); + writeInputMatrixWithMTD("A", A, false); + + //run performance tests + runTest(true, false, null, -1); + + //compare output meta data + boolean left = (testname.equals(TEST_NAME1) || testname.equals(TEST_NAME3)); + boolean pos = (testname.equals(TEST_NAME1) || testname.equals(TEST_NAME2)); + int rrows = (left && pos) ? rows : outDim; + int rcols = (!left && pos) ? rows : outDim; + checkDMLMetaDataFile("R", new MatrixCharacteristics(rrows, rcols, 1, 1)); + + //check for applied rewrite + Assert.assertEquals(new Boolean(testname.equals(TEST_NAME1)||testname.equals(TEST_NAME2)), + new Boolean(heavyHittersContainsSubString("rexpand"))); + } +} http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftNeg.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftNeg.dml b/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftNeg.dml new file mode 100644 index 0000000..92d12a1 --- /dev/null +++ b/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftNeg.dml @@ -0,0 +1,27 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + + +A = read($1); + +R = table(seq(1,nrow(A)), A, $2, $2); + +write(R, $3); http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftPos.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftPos.dml b/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftPos.dml new file mode 100644 index 0000000..1217355 --- /dev/null +++ b/src/test/scripts/functions/misc/RewriteCTableToRExpandLeftPos.dml @@ -0,0 +1,27 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + + +A = read($1); + +R = table(seq(1,nrow(A)), A, nrow(A), $2); + +write(R, $3); http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test/scripts/functions/misc/RewriteCTableToRExpandRightNeg.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/RewriteCTableToRExpandRightNeg.dml b/src/test/scripts/functions/misc/RewriteCTableToRExpandRightNeg.dml new file mode 100644 index 0000000..d346846 --- /dev/null +++ b/src/test/scripts/functions/misc/RewriteCTableToRExpandRightNeg.dml @@ -0,0 +1,27 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + + +A = read($1); + +R = table(A, seq(1,nrow(A)), $2, $2); + +write(R, $3); http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test/scripts/functions/misc/RewriteCTableToRExpandRightPos.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/RewriteCTableToRExpandRightPos.dml b/src/test/scripts/functions/misc/RewriteCTableToRExpandRightPos.dml new file mode 100644 index 0000000..8e66116 --- /dev/null +++ b/src/test/scripts/functions/misc/RewriteCTableToRExpandRightPos.dml @@ -0,0 +1,27 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + + +A = read($1); + +R = table(A, seq(1,nrow(A)), $2, nrow(A)); + +write(R, $3); http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/5937df93/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java ---------------------------------------------------------------------- diff --git a/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java b/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java index 1b3478d..6d7daaf 100644 --- a/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java +++ b/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java @@ -47,6 +47,7 @@ import org.junit.runners.Suite; PrintMatrixTest.class, ReadAfterWriteTest.class, RewriteCSETransposeScalarTest.class, + RewriteCTableToRExpandTest.class, RewriteFusedRandTest.class, RewriteLoopVectorization.class, RewritePushdownSumBinaryMult.class,