[SYSTEMML-2201] Fix removeEmpty empty.return handling in cp/mr SYSTEMML-2135 introduced the handling of matrices with zero rows and columns in order to resolve (among others) special cases of removeEmpty, where we returned a single empty row/column for empty inputs. For backwards compatibility, we introduced an optimal parameter 'empty.return=true' to explicitly influence this behavior. However, this parameter was mistakenly ignored in CP and MR instructions.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/1c0efe31 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/1c0efe31 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/1c0efe31 Branch: refs/heads/master Commit: 1c0efe31a827884e8bf297e97ca5cbed9d13c93a Parents: 967b731 Author: Matthias Boehm <[email protected]> Authored: Wed Mar 21 23:40:40 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Wed Mar 21 23:41:05 2018 -0700 ---------------------------------------------------------------------- .../sysml/hops/ParameterizedBuiltinOp.java | 15 ++-- .../sysml/hops/rewrite/HopRewriteUtils.java | 5 ++ .../apache/sysml/lops/ParameterizedBuiltin.java | 77 ++++---------------- .../cp/ParameterizedBuiltinCPInstruction.java | 3 +- .../mr/RemoveEmptyMRInstruction.java | 55 +++++++++----- .../runtime/matrix/MatrixCharacteristics.java | 5 +- .../functions/misc/ZeroRowsColsMatrixTest.java | 54 +++++++++++--- .../functions/misc/ZeroMatrix_Aggregates.R | 2 +- .../functions/misc/ZeroMatrix_Aggregates.dml | 2 +- .../scripts/functions/misc/ZeroMatrix_Cbind.R | 2 +- .../scripts/functions/misc/ZeroMatrix_Cbind.dml | 2 +- .../scripts/functions/misc/ZeroMatrix_Rbind.R | 2 +- .../scripts/functions/misc/ZeroMatrix_Rbind.dml | 2 +- .../functions/misc/ZeroMatrix_RemoveEmpty.R | 5 +- .../functions/misc/ZeroMatrix_RemoveEmpty.dml | 7 +- 15 files changed, 128 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/main/java/org/apache/sysml/hops/ParameterizedBuiltinOp.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/ParameterizedBuiltinOp.java b/src/main/java/org/apache/sysml/hops/ParameterizedBuiltinOp.java index e9800a5..302fb7a 100644 --- a/src/main/java/org/apache/sysml/hops/ParameterizedBuiltinOp.java +++ b/src/main/java/org/apache/sysml/hops/ParameterizedBuiltinOp.java @@ -408,6 +408,7 @@ public class ParameterizedBuiltinOp extends Hop implements MultiThreadedHop Hop targetHop = getTargetHop(); Hop marginHop = getParameterHop("margin"); Hop selectHop = getParameterHop("select"); + Hop emptyRet = getParameterHop("empty.return"); if( et == ExecType.CP || et == ExecType.CP_FILE ) { @@ -474,8 +475,8 @@ public class ParameterizedBuiltinOp extends Hop implements MultiThreadedHop else if( et == ExecType.MR ) { //special compile for mr removeEmpty-diag - if( isTargetDiagInput() && marginHop instanceof LiteralOp - && ((LiteralOp)marginHop).getStringValue().equals("rows") ) + if( isTargetDiagInput() + && HopRewriteUtils.isLiteralOfValue(marginHop, "rows") ) { //get input vector (without materializing diag()) Hop input = targetHop.getInput().get(0); @@ -602,13 +603,14 @@ public class ParameterizedBuiltinOp extends Hop implements MultiThreadedHop Lop rmEmpty = null; //a) broadcast-based PMM (permutation matrix mult) - if( rmRows && rlen >= 0 && mestPM < OptimizerUtils.getRemoteMemBudgetMap() ) + if( rmRows && rlen >= 0 && mestPM < OptimizerUtils.getRemoteMemBudgetMap() + && HopRewriteUtils.isLiteralOfValue(emptyRet, false)) { boolean needPart = !offsets.dimsKnown() || offsets.getDim1() > DistributedCacheInput.PARTITION_SIZE; if( needPart ){ //requires partitioning loffset = new DataPartition(loffset, DataType.MATRIX, ValueType.DOUBLE, (mestPM>OptimizerUtils.getLocalMemBudget())?ExecType.MR:ExecType.CP, PDataPartitionFormat.ROW_BLOCK_WISE_N); loffset.getOutputParameters().setDimensions(rlen, 1, brlen, bclen, rlen); - setLineNumbers(loffset); + setLineNumbers(loffset); } rmEmpty = new PMMJ(loffset, linput, lmaxdim, getDataType(), getValueType(), needPart, true, ExecType.MR); @@ -618,8 +620,8 @@ public class ParameterizedBuiltinOp extends Hop implements MultiThreadedHop //b) general case: repartition-based rmempty else { - boolean requiresRep = ((clen>bclen || clen<=0) && rmRows) - || ((rlen>brlen || rlen<=0) && !rmRows); + boolean requiresRep = ((clen>bclen || clen<=0) && rmRows) + || ((rlen>brlen || rlen<=0) && !rmRows); if( requiresRep ) { Lop pos = createOffsetLop(input, rmRows); //ncol of left input (determines num replicates) @@ -641,6 +643,7 @@ public class ParameterizedBuiltinOp extends Hop implements MultiThreadedHop inMap.put("offset", group2); inMap.put("maxdim", lmaxdim); inMap.put("margin", inputlops.get("margin")); + inMap.put("empty.return", inputlops.get("empty.return")); rmEmpty = new ParameterizedBuiltin(inMap, HopsParameterizedBuiltinLops.get(_op), getDataType(), getValueType(), et); setOutputDimensions(rmEmpty); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/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 735cac0..74711e3 100644 --- a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java +++ b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java @@ -201,6 +201,11 @@ public class HopRewriteUtils && getDoubleValueSafe((LiteralOp)hop)==val); } + public static boolean isLiteralOfValue(Hop hop, String val) { + return hop instanceof LiteralOp + && ((LiteralOp)hop).getStringValue().equals(val); + } + public static boolean isLiteralOfValue( Hop hop, boolean val ) { try { return (hop instanceof LiteralOp http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/main/java/org/apache/sysml/lops/ParameterizedBuiltin.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/lops/ParameterizedBuiltin.java b/src/main/java/org/apache/sysml/lops/ParameterizedBuiltin.java index 6df8308..1188f1b 100644 --- a/src/main/java/org/apache/sysml/lops/ParameterizedBuiltin.java +++ b/src/main/java/org/apache/sysml/lops/ParameterizedBuiltin.java @@ -288,107 +288,60 @@ public class ParameterizedBuiltin extends Lop } @Override - public String getInstructions(int input_index1, int input_index2, int input_index3, int input_index4, int output_index) + public String getInstructions(int input_index1, int input_index2, int input_index3, int input_index4, int input_index5, int output_index) throws LopsException { + int[] tmp = new int[]{input_index1, input_index2, + input_index3, input_index4, input_index5}; + StringBuilder sb = new StringBuilder(); sb.append( getExecType() ); sb.append( Lop.OPERAND_DELIMITOR ); - - switch(_operation) - { - case RMEMPTY: - { + + switch(_operation) { + case RMEMPTY: { sb.append("rmempty"); - sb.append(OPERAND_DELIMITOR); - Lop iLop1 = _inputParams.get("target"); - int pos1 = getInputs().indexOf(iLop1); - int index1 = (pos1==0)? input_index1 : (pos1==1)? input_index2 : (pos1==2)? input_index3 : input_index4; - sb.append(prepInputOperand(index1)); - + sb.append(prepInputOperand(tmp[getInputs().indexOf(iLop1)])); sb.append(OPERAND_DELIMITOR); - Lop iLop2 = _inputParams.get("offset"); - int pos2 = getInputs().indexOf(iLop2); - int index2 = (pos2==0)? input_index1 : (pos2==1)? input_index2 : (pos1==2)? input_index3 : input_index4; - sb.append(prepInputOperand(index2)); - + sb.append(prepInputOperand(tmp[getInputs().indexOf(iLop2)])); sb.append(OPERAND_DELIMITOR); - Lop iLop3 = _inputParams.get("maxdim"); sb.append( iLop3.prepScalarLabel() ); - sb.append(OPERAND_DELIMITOR); - Lop iLop4 = _inputParams.get("margin"); sb.append( iLop4.prepScalarLabel() ); - - sb.append( OPERAND_DELIMITOR ); - + sb.append(OPERAND_DELIMITOR); + Lop iLop5 = _inputParams.get("empty.return"); + sb.append( iLop5.prepScalarLabel() ); break; } - - default: - throw new LopsException(this.printErrorLocation() + "In ParameterizedBuiltin Lop, Unknown operation: " + _operation); - } - - sb.append( prepOutputOperand(output_index)); - - return sb.toString(); - } - - @Override - public String getInstructions(int input_index1, int input_index2, int input_index3, int input_index4, int input_index5, int output_index) - throws LopsException - { - StringBuilder sb = new StringBuilder(); - sb.append( getExecType() ); - sb.append( Lop.OPERAND_DELIMITOR ); - - switch(_operation) - { - case REXPAND: - { + case REXPAND: { sb.append("rexpand"); - sb.append(OPERAND_DELIMITOR); - Lop iLop1 = _inputParams.get("target"); - int pos1 = getInputs().indexOf(iLop1); - int index1 = (pos1==0)? input_index1 : (pos1==1)? input_index2 : (pos1==2)? input_index3 : (pos1==3)? input_index4 : input_index5; - sb.append(prepInputOperand(index1)); - + sb.append(prepInputOperand(tmp[getInputs().indexOf(iLop1)])); sb.append(OPERAND_DELIMITOR); - Lop iLop2 = _inputParams.get("max"); sb.append( iLop2.prepScalarLabel() ); - sb.append(OPERAND_DELIMITOR); - Lop iLop3 = _inputParams.get("dir"); sb.append( iLop3.prepScalarLabel() ); - sb.append(OPERAND_DELIMITOR); - Lop iLop4 = _inputParams.get("cast"); sb.append( iLop4.prepScalarLabel() ); - sb.append( OPERAND_DELIMITOR ); - Lop iLop5 = _inputParams.get("ignore"); sb.append( iLop5.prepScalarLabel() ); - - sb.append( OPERAND_DELIMITOR ); - break; } - default: throw new LopsException(this.printErrorLocation() + "In ParameterizedBuiltin Lop, Unknown operation: " + _operation); } + sb.append( OPERAND_DELIMITOR ); sb.append( prepOutputOperand(output_index)); return sb.toString(); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/main/java/org/apache/sysml/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java index 18ec72c..f7a491e 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java @@ -206,8 +206,9 @@ public class ParameterizedBuiltinCPInstruction extends ComputationCPInstruction MatrixBlock select = params.containsKey("select")? ec.getMatrixInput(params.get("select"), getExtendedOpcode()):null; // compute the result + boolean emptyReturn = Boolean.parseBoolean(params.get("empty.return").toLowerCase()); MatrixBlock soresBlock = target.removeEmptyOperations(new MatrixBlock(), - margin.equals("rows"), margin.equals("empty.return"), select); + margin.equals("rows"), emptyReturn, select); //release locks ec.setMatrixOutput(output.getName(), soresBlock, getExtendedOpcode()); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/main/java/org/apache/sysml/runtime/instructions/mr/RemoveEmptyMRInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/mr/RemoveEmptyMRInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/mr/RemoveEmptyMRInstruction.java index 79445c7..fa26152 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/mr/RemoveEmptyMRInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/mr/RemoveEmptyMRInstruction.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.instructions.InstructionUtils; import org.apache.sysml.runtime.matrix.data.LibMatrixReorg; +import org.apache.sysml.runtime.matrix.data.MatrixBlock; +import org.apache.sysml.runtime.matrix.data.MatrixIndexes; import org.apache.sysml.runtime.matrix.data.MatrixValue; import org.apache.sysml.runtime.matrix.mapred.CachedValueMap; import org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue; @@ -36,30 +38,34 @@ import org.apache.sysml.runtime.util.UtilFunctions; * */ public class RemoveEmptyMRInstruction extends BinaryInstruction { - private long _len = -1; - private boolean _rmRows = true; + private final long _len; + private final boolean _rmRows; + private final boolean _emptyRet; - private RemoveEmptyMRInstruction(Operator op, byte in1, byte in2, long len, boolean rmRows, byte out, String istr) { + private RemoveEmptyMRInstruction(Operator op, byte in1, byte in2, long len, boolean rmRows, boolean emptyRet, byte out, String istr) { super(MRType.RemoveEmpty, op, in1, in2, out, istr); instString = istr; _len = len; _rmRows = rmRows; + _emptyRet = emptyRet; } - public boolean isRemoveRows() - { + public boolean isRemoveRows() { return _rmRows; } - public long getOutputLen() - { + public boolean isEmptyReturn() { + return _emptyRet; + } + + public long getOutputLen() { return _len; } public static RemoveEmptyMRInstruction parseInstruction ( String str ) throws DMLRuntimeException { - InstructionUtils.checkNumFields ( str, 5 ); + InstructionUtils.checkNumFields (str, 6); String[] parts = InstructionUtils.getInstructionParts(str); String opcode = parts[0]; @@ -71,27 +77,38 @@ public class RemoveEmptyMRInstruction extends BinaryInstruction { byte in2 = Byte.parseByte(parts[2]); long rlen = UtilFunctions.toLong(Double.parseDouble(parts[3])); boolean rmRows = parts[4].equals("rows"); - byte out = Byte.parseByte(parts[5]); + boolean emptyRet = Boolean.parseBoolean(parts[5].toLowerCase()); + byte out = Byte.parseByte(parts[6]); - return new RemoveEmptyMRInstruction(null, in1, in2, rlen, rmRows, out, str); + return new RemoveEmptyMRInstruction(null, in1, in2, rlen, rmRows, emptyRet, out, str); } @Override public void processInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) - throws DMLRuntimeException - { + throws DMLRuntimeException + { //get input and offsets IndexedMatrixValue inData = cachedValues.getFirst(input1); IndexedMatrixValue inOffset = cachedValues.getFirst(input2); - - //execute remove empty operations - ArrayList<IndexedMatrixValue> out = new ArrayList<>(); - LibMatrixReorg.rmempty(inData, inOffset, _rmRows, _len, blockRowFactor, blockColFactor, out); + MatrixIndexes ix = inData.getIndexes(); + MatrixValue mb = inData.getValue(); - //put results into cache map - for( IndexedMatrixValue imv : out ) - cachedValues.add(output, imv); + if( _len > 0 ) { + //execute remove empty operations + ArrayList<IndexedMatrixValue> out = new ArrayList<>(); + LibMatrixReorg.rmempty(inData, inOffset, _rmRows, _len, blockRowFactor, blockColFactor, out); + + //put results into cache map + for( IndexedMatrixValue imv : out ) + cachedValues.add(output, imv); + } + else { + int n = _emptyRet ? 1 : 0; + cachedValues.add(output, new IndexedMatrixValue( + new MatrixIndexes(_rmRows?1:ix.getRowIndex(), _rmRows?ix.getColumnIndex():1), + new MatrixBlock(_rmRows?n:mb.getNumRows(), _rmRows?mb.getNumColumns():n, false))); + } } } http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/main/java/org/apache/sysml/runtime/matrix/MatrixCharacteristics.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/matrix/MatrixCharacteristics.java b/src/main/java/org/apache/sysml/runtime/matrix/MatrixCharacteristics.java index 7766162..e9554f9 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/MatrixCharacteristics.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/MatrixCharacteristics.java @@ -362,10 +362,11 @@ public class MatrixCharacteristics implements Serializable { RemoveEmptyMRInstruction realIns=(RemoveEmptyMRInstruction)ins; MatrixCharacteristics mc = dims.get(realIns.input1); + long min = realIns.isEmptyReturn() ? 1 : 0; if( realIns.isRemoveRows() ) - dimOut.set(realIns.getOutputLen(), mc.getCols(), mc.numRowsPerBlock, mc.numColumnsPerBlock); + dimOut.set(Math.max(realIns.getOutputLen(),min), mc.getCols(), mc.numRowsPerBlock, mc.numColumnsPerBlock); else - dimOut.set(mc.getRows(), realIns.getOutputLen(), mc.numRowsPerBlock, mc.numColumnsPerBlock); + dimOut.set(mc.getRows(), Math.max(realIns.getOutputLen(), min), mc.numRowsPerBlock, mc.numColumnsPerBlock); } else if(ins instanceof UaggOuterChainInstruction) //needs to be checked before binary { http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/java/org/apache/sysml/test/integration/functions/misc/ZeroRowsColsMatrixTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/misc/ZeroRowsColsMatrixTest.java b/src/test/java/org/apache/sysml/test/integration/functions/misc/ZeroRowsColsMatrixTest.java index 7574fb6..d4c6a30 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/misc/ZeroRowsColsMatrixTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/misc/ZeroRowsColsMatrixTest.java @@ -54,33 +54,63 @@ public class ZeroRowsColsMatrixTest extends AutomatedTestBase } @Test + public void testEmptyMatrixRemoveEmptyNoRewritesEmptyRetCP() { + runEmptyMatrixTest(TEST_NAME1, false, true, ExecType.CP); + } + + @Test + public void testEmptyMatrixRemoveEmptyRewritesEmptyRetCP() { + runEmptyMatrixTest(TEST_NAME1, true, true, ExecType.CP); + } + + @Test + public void testEmptyMatrixRemoveEmptyNoRewritesEmptyRetMR() { + runEmptyMatrixTest(TEST_NAME1, false, true, ExecType.MR); + } + + @Test + public void testEmptyMatrixRemoveEmptyRewritesEmptyRetMR() { + runEmptyMatrixTest(TEST_NAME1, true, true, ExecType.MR); + } + + @Test + public void testEmptyMatrixRemoveEmptyNoRewritesEmptyRetSP() { + runEmptyMatrixTest(TEST_NAME1, false, true, ExecType.SPARK); + } + + @Test + public void testEmptyMatrixRemoveEmptyRewritesEmptyRetSP() { + runEmptyMatrixTest(TEST_NAME1, true, true, ExecType.SPARK); + } + + @Test public void testEmptyMatrixRemoveEmptyNoRewritesCP() { - runEmptyMatrixTest(TEST_NAME1, false, ExecType.CP); + runEmptyMatrixTest(TEST_NAME1, false, false, ExecType.CP); } @Test public void testEmptyMatrixRemoveEmptyRewritesCP() { - runEmptyMatrixTest(TEST_NAME1, true, ExecType.CP); + runEmptyMatrixTest(TEST_NAME1, true, false, ExecType.CP); } @Test public void testEmptyMatrixRemoveEmptyNoRewritesMR() { - runEmptyMatrixTest(TEST_NAME1, false, ExecType.MR); + runEmptyMatrixTest(TEST_NAME1, false, false, ExecType.MR); } @Test public void testEmptyMatrixRemoveEmptyRewritesMR() { - runEmptyMatrixTest(TEST_NAME1, true, ExecType.MR); + runEmptyMatrixTest(TEST_NAME1, true, false, ExecType.MR); } @Test public void testEmptyMatrixRemoveEmptyNoRewritesSP() { - runEmptyMatrixTest(TEST_NAME1, false, ExecType.SPARK); + runEmptyMatrixTest(TEST_NAME1, false, false, ExecType.SPARK); } @Test public void testEmptyMatrixRemoveEmptyRewritesSP() { - runEmptyMatrixTest(TEST_NAME1, true, ExecType.SPARK); + runEmptyMatrixTest(TEST_NAME1, true, false, ExecType.SPARK); } @Test @@ -173,7 +203,11 @@ public class ZeroRowsColsMatrixTest extends AutomatedTestBase runEmptyMatrixTest(TEST_NAME4, true, ExecType.SPARK); } - private void runEmptyMatrixTest( String testname, boolean rewrites, ExecType et ) + private void runEmptyMatrixTest( String testname, boolean rewrites, ExecType et ) { + runEmptyMatrixTest(testname, rewrites, false, et); + } + + private void runEmptyMatrixTest( String testname, boolean rewrites, boolean emptyRet, ExecType et ) { RUNTIME_PLATFORM platformOld = rtplatform; switch( et ){ @@ -196,10 +230,12 @@ public class ZeroRowsColsMatrixTest extends AutomatedTestBase String HOME = SCRIPT_DIR + TEST_DIR; fullDMLScriptName = HOME + TEST_NAME + ".dml"; - programArgs = new String[]{"-explain","recompile_runtime","-args", String.valueOf(dim), output("R")}; + programArgs = new String[]{"-explain","recompile_runtime","-args", String.valueOf(dim), + String.valueOf(emptyRet).toUpperCase(), output("R")}; fullRScriptName = HOME + TEST_NAME +".R"; - rCmd = getRCmd(String.valueOf(dim), expectedDir()); + rCmd = getRCmd(String.valueOf(dim), + String.valueOf(emptyRet).toUpperCase(), expectedDir()); //run Tests runTest(true, false, null, -1); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.R ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.R b/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.R index bc105e6..2fdf920 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.R +++ b/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.R @@ -33,4 +33,4 @@ R = rbind(rbind(rbind(rbind( as.matrix(is.nan(mean(X)))), as.matrix(is.na(sd(X)))); -writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep="")); +writeMM(as(R, "CsparseMatrix"), paste(args[3], "R", sep="")); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.dml b/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.dml index f26f516..f2975f0 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.dml +++ b/src/test/scripts/functions/misc/ZeroMatrix_Aggregates.dml @@ -29,4 +29,4 @@ R = rbind(rbind(rbind(rbind( as.matrix(mean(X)!=mean(X))), # NaN as.matrix(sd(X)!=sd(X))); # NaN -write(R, $2); +write(R, $3); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Cbind.R ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Cbind.R b/src/test/scripts/functions/misc/ZeroMatrix_Cbind.R index fb520fd..a468f24 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Cbind.R +++ b/src/test/scripts/functions/misc/ZeroMatrix_Cbind.R @@ -29,4 +29,4 @@ R = matrix(0, n, 0); for( i in 1:3 ) R = cbind(R, matrix(7, n, 1)); -writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep="")); +writeMM(as(R, "CsparseMatrix"), paste(args[3], "R", sep="")); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Cbind.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Cbind.dml b/src/test/scripts/functions/misc/ZeroMatrix_Cbind.dml index 7544ac2..00d5113 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Cbind.dml +++ b/src/test/scripts/functions/misc/ZeroMatrix_Cbind.dml @@ -26,4 +26,4 @@ for( i in 1:3 ) { R = cbind(R, matrix(7, $1, 1)); print(nrow(R) + " " + ncol(R) + " " + length(R)); } -write(R, $2); +write(R, $3); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Rbind.R ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Rbind.R b/src/test/scripts/functions/misc/ZeroMatrix_Rbind.R index 656c654..89b5726 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Rbind.R +++ b/src/test/scripts/functions/misc/ZeroMatrix_Rbind.R @@ -30,4 +30,4 @@ for( i in 1:3 ) R = rbind(R, matrix(7, 1, n)); R = t(R); -writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep="")); +writeMM(as(R, "CsparseMatrix"), paste(args[3], "R", sep="")); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_Rbind.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_Rbind.dml b/src/test/scripts/functions/misc/ZeroMatrix_Rbind.dml index 7400c9a..f2aee30 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_Rbind.dml +++ b/src/test/scripts/functions/misc/ZeroMatrix_Rbind.dml @@ -28,4 +28,4 @@ for( i in 1:3 ) { } R = t(R); -write(R, $2); +write(R, $3); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.R ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.R b/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.R index 0814e92..aec109b 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.R +++ b/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.R @@ -24,6 +24,7 @@ args <- commandArgs(TRUE) options(digits=22) library("Matrix") -R = matrix(7, as.integer(args[1]), 3); +val = 7 + ifelse(as.logical(args[2]), 2, 0); +R = matrix(val, as.integer(args[1]), 3); -writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep="")); +writeMM(as(R, "CsparseMatrix"), paste(args[3], "R", sep="")); http://git-wip-us.apache.org/repos/asf/systemml/blob/1c0efe31/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.dml b/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.dml index 479bd9e..f16a2c0 100644 --- a/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.dml +++ b/src/test/scripts/functions/misc/ZeroMatrix_RemoveEmpty.dml @@ -21,8 +21,9 @@ A = matrix(0, $1, $1); -B = removeEmpty(target=A, margin="rows", empty.return=FALSE); -C = removeEmpty(target=A, margin="cols", empty.return=FALSE); +eret = as.logical($2); +B = removeEmpty(target=A, margin="rows", empty.return=eret); +C = removeEmpty(target=A, margin="cols", empty.return=eret); R = matrix(7+nrow(B)+ncol(C), $1, 3); -write(R, $2); \ No newline at end of file +write(R, $3); \ No newline at end of file
