You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2017/10/18 04:39:31 UTC
[2/2] systemml git commit: [MINOR] Fix missing warning on truncation
of matrix/frame toString
[MINOR] Fix missing warning on truncation of matrix/frame toString
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/5b8d6265
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/5b8d6265
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/5b8d6265
Branch: refs/heads/master
Commit: 5b8d62659b2e5727bebcaf0d2681fc4ecd4ea85f
Parents: 60ad522
Author: Matthias Boehm <mb...@gmail.com>
Authored: Tue Oct 17 20:54:01 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Tue Oct 17 21:39:58 2017 -0700
----------------------------------------------------------------------
.../cp/ParameterizedBuiltinCPInstruction.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/systemml/blob/5b8d6265/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 e8a5f4a..f6532d7 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
@@ -26,6 +26,7 @@ import org.apache.sysml.lops.Lop;
import org.apache.sysml.parser.ParameterizedBuiltinFunctionExpression;
import org.apache.sysml.parser.Statement;
import org.apache.sysml.runtime.DMLRuntimeException;
+import org.apache.sysml.runtime.controlprogram.caching.CacheBlock;
import org.apache.sysml.runtime.controlprogram.caching.CacheableData;
import org.apache.sysml.runtime.controlprogram.caching.FrameObject;
import org.apache.sysml.runtime.controlprogram.caching.MatrixObject;
@@ -328,10 +329,12 @@ public class ParameterizedBuiltinCPInstruction extends ComputationCPInstruction
String out = null;
if( data instanceof MatrixObject ) {
MatrixBlock matrix = (MatrixBlock) data.acquireRead();
+ warnOnTrunction(matrix, rows, cols);
out = DataConverter.toString(matrix, sparse, separator, lineseparator, rows, cols, decimal);
}
else if( data instanceof FrameObject ) {
FrameBlock frame = (FrameBlock) data.acquireRead();
+ warnOnTrunction(frame, rows, cols);
out = DataConverter.toString(frame, sparse, separator, lineseparator, rows, cols, decimal);
}
else {
@@ -342,6 +345,17 @@ public class ParameterizedBuiltinCPInstruction extends ComputationCPInstruction
}
else {
throw new DMLRuntimeException("Unknown opcode : " + opcode);
- }
+ }
+ }
+
+ private void warnOnTrunction(CacheBlock data, int rows, int cols) {
+ //warn on truncation because users might not be aware and use toString for verification
+ if( (getParam("rows")==null && data.getNumRows()>rows)
+ || (getParam("cols")==null && data.getNumColumns()>cols) )
+ {
+ LOG.warn("Truncating "+data.getClass().getSimpleName()+" of size "
+ + data.getNumRows()+"x"+data.getNumColumns()+" to "+rows+"x"+cols+". "
+ + "Use toString(X, rows=..., cols=...) if necessary.");
+ }
}
}