This is an automated email from the ASF dual-hosted git repository.

niketanpansare pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemml.git


The following commit(s) were added to refs/heads/master by this push:
     new 881f606  [MINOR] Provide a more informative error message when the 
dimensions don't match during the validate phase
881f606 is described below

commit 881f606a89a5683e1a41a1c974fc0188d8600ade
Author: Niketan Pansare <npan...@us.ibm.com>
AuthorDate: Wed Mar 13 14:47:11 2019 -0700

    [MINOR] Provide a more informative error message when the dimensions don't 
match during the validate phase
---
 .../org/apache/sysml/parser/BuiltinFunctionExpression.java  | 13 ++++++++++---
 .../java/org/apache/sysml/parser/RelationalExpression.java  |  7 +++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java 
b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
index fe86dc8..f27958f 100644
--- a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
+++ b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
@@ -1717,8 +1717,11 @@ public class BuiltinFunctionExpression extends 
DataIdentifier
                                  || (!allowsMV && expr1.getOutput().getDim2() 
!= expr2.getOutput().getDim2()) 
                                  || (allowsMV && expr1.getOutput().getDim2() 
!= expr2.getOutput().getDim2() && expr2.getOutput().getDim2() != 1) ) 
                        {
-                               raiseValidateError("Mismatch in matrix 
dimensions of parameters for function "
-                                               + this.getOpCode(), 
conditional, LanguageErrorCodes.INVALID_PARAMETERS);
+                               String str1 = "([" + 
expr1.getOutput().getDim1() + ", " + expr1.getOutput().getDim2()  + "] and [" 
+                                               + expr2.getOutput().getDim1() + 
", " + expr2.getOutput().getDim2()  + "])";
+                               String str2 = !allowsMV ? " (Note: " + 
this.getOpCode() + " does not support matrix-vector operations)" : "";
+                               raiseValidateError("Mismatch in matrix 
dimensions " + str1 + " of parameters for function "
+                                               + this.getOpCode() + str2, 
conditional, LanguageErrorCodes.INVALID_PARAMETERS);
                        }
                }
        }
@@ -1726,7 +1729,11 @@ public class BuiltinFunctionExpression extends 
DataIdentifier
        private void checkMatchingDimensionsQuantile() 
        {
                if (getFirstExpr().getOutput().getDim1() != 
getSecondExpr().getOutput().getDim1()) {
-                       raiseValidateError("Mismatch in matrix dimensions for "
+                       Expression expr1 = getFirstExpr();
+                       Expression expr2 = getSecondExpr();
+                       String str1 = "([" + expr1.getOutput().getDim1() + ", " 
+ expr1.getOutput().getDim2()  + "] and [" 
+                                       + expr2.getOutput().getDim1() + ", " + 
expr2.getOutput().getDim2()  + "])";
+                       raiseValidateError("Mismatch in matrix dimensions " + 
str1 + " of parameters for "
                                        + this.getOpCode(), false, 
LanguageErrorCodes.INVALID_PARAMETERS);
                }
        }
diff --git a/src/main/java/org/apache/sysml/parser/RelationalExpression.java 
b/src/main/java/org/apache/sysml/parser/RelationalExpression.java
index eed568c..8d897c7 100644
--- a/src/main/java/org/apache/sysml/parser/RelationalExpression.java
+++ b/src/main/java/org/apache/sysml/parser/RelationalExpression.java
@@ -182,8 +182,11 @@ public class RelationalExpression extends Expression
                                  || (!allowsMV && expr1.getOutput().getDim2() 
!= expr2.getOutput().getDim2()) 
                                  || (allowsMV && expr1.getOutput().getDim2() 
!= expr2.getOutput().getDim2() && expr2.getOutput().getDim2() != 1) ) 
                        {
-                               raiseValidateError("Mismatch in matrix 
dimensions of parameters for function "
-                                               + this.getOpCode(), false, 
LanguageErrorCodes.INVALID_PARAMETERS);
+                               String str1 = "([" + 
expr1.getOutput().getDim1() + ", " + expr1.getOutput().getDim2()  + "] and [" 
+                                               + expr2.getOutput().getDim1() + 
", " + expr2.getOutput().getDim2()  + "])";
+                               String str2 = !allowsMV ? " (Note: " + 
this.getOpCode() + " does not support matrix-vector operations)" : "";
+                               raiseValidateError("Mismatch in matrix 
dimensions " + str1 + " of parameters for function "
+                                               + this.getOpCode() + str2, 
false, LanguageErrorCodes.INVALID_PARAMETERS);
                        }
                }
        }

Reply via email to