Repository: systemml Updated Branches: refs/heads/master 4d370a8a6 -> 87bc3584d
[HOTFIX] Fix validation of scalar-scalar binary min/max operations This recent introduction of nary min/max operations corrupted the language validation path for scalar-scalar operations. This patch fixes various issues related to (1) value type inference, (2) output dimension/blocksize propagation, and (3) the handling of all scalar nary min/max operations. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/87bc3584 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/87bc3584 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/87bc3584 Branch: refs/heads/master Commit: 87bc3584db2148cf78b2d46418639e88ca27ec64 Parents: 4d370a8 Author: Matthias Boehm <[email protected]> Authored: Thu Jun 7 23:53:31 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Thu Jun 7 23:53:31 2018 -0700 ---------------------------------------------------------------------- .../sysml/parser/BuiltinFunctionExpression.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/87bc3584/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java index d38f445..3514e6b 100644 --- a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java +++ b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java @@ -574,8 +574,7 @@ public class BuiltinFunctionExpression extends DataIdentifier case MIN: case MAX: //min(X), min(X,s), min(s,X), min(s,r), min(X,Y) - //unary - if (getSecondExpr() == null) { + if (getSecondExpr() == null) { //unary checkNumParameters(1); checkMatrixParam(getFirstExpr()); output.setDataType(DataType.SCALAR); @@ -583,9 +582,11 @@ public class BuiltinFunctionExpression extends DataIdentifier output.setDimensions(0, 0); output.setBlockDimensions (0, 0); } - - //nary operation - else { + else if( getAllExpr().length == 2 ) { //binary + checkNumParameters(2); + setBinaryOutputProperties(output); + } + else { //nary for( Expression e : getAllExpr() ) checkMatrixScalarParam(e); setNaryOutputProperties(output); @@ -1463,7 +1464,7 @@ public class BuiltinFunctionExpression extends DataIdentifier e -> e.getOutput().getDataType().isScalar()) ? DataType.SCALAR : DataType.MATRIX; Expression firstM = dt.isMatrix() ? Arrays.stream(getAllExpr()).filter( e -> e.getOutput().getDataType().isMatrix()).findFirst().get() : null; - ValueType vt = dt.isMatrix() ? ValueType.DOUBLE : ValueType.BOOLEAN; + ValueType vt = dt.isMatrix() ? ValueType.DOUBLE : ValueType.INT; for( Expression e : getAllExpr() ) { vt = computeValueType(e, e.getOutput().getValueType(), vt, true); if( e.getOutput().getDataType().isMatrix() ) @@ -1471,9 +1472,10 @@ public class BuiltinFunctionExpression extends DataIdentifier } output.setDataType(dt); output.setValueType(vt); - output.setDimensions(firstM.getOutput().getDim1(), firstM.getOutput().getDim2()); - output.setBlockDimensions ( - firstM.getOutput().getRowsInBlock(), firstM.getOutput().getColumnsInBlock()); + output.setDimensions(dt.isMatrix() ? firstM.getOutput().getDim1() : 0, + dt.isMatrix() ? firstM.getOutput().getDim2() : 0); + output.setBlockDimensions (dt.isMatrix() ? firstM.getOutput().getRowsInBlock() : 0, + dt.isMatrix() ? firstM.getOutput().getColumnsInBlock() : 0); } private void expandArguments() {
