You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by ni...@apache.org on 2017/09/08 22:54:45 UTC
systemml git commit: [SYSTEMML-540] [MINOR] Throw user-friendly
message for invalid convolution parameters
Repository: systemml
Updated Branches:
refs/heads/master 8395ffb29 -> 3b8a86065
[SYSTEMML-540] [MINOR] Throw user-friendly message for invalid convolution parameters
- This commit checks if the given parameters generates an output
activation of negative dimensions.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/3b8a8606
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/3b8a8606
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/3b8a8606
Branch: refs/heads/master
Commit: 3b8a86065452e77b41525098d92f6f11f5419be3
Parents: 8395ffb
Author: Niketan Pansare <np...@us.ibm.com>
Authored: Fri Sep 8 14:54:22 2017 -0800
Committer: Niketan Pansare <np...@us.ibm.com>
Committed: Fri Sep 8 15:54:21 2017 -0700
----------------------------------------------------------------------
.../sysml/runtime/util/ConvolutionUtils.java | 22 ++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/systemml/blob/3b8a8606/src/main/java/org/apache/sysml/runtime/util/ConvolutionUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/util/ConvolutionUtils.java b/src/main/java/org/apache/sysml/runtime/util/ConvolutionUtils.java
index 07da5bc..046dbac 100644
--- a/src/main/java/org/apache/sysml/runtime/util/ConvolutionUtils.java
+++ b/src/main/java/org/apache/sysml/runtime/util/ConvolutionUtils.java
@@ -47,13 +47,31 @@ public class ConvolutionUtils {
if(H <= 0 || R <= 0 || heightPadding < 0 || verticalStride < 0) {
throw new RuntimeException("Incorrect parameters: height=" + H + " filter_height=" + R + " stride=" + verticalStride + " pad=" + heightPadding);
}
- return (H + 2 * heightPadding - R) / verticalStride + 1;
+ long padded_image_height = H + 2 * heightPadding;
+ long ret = (padded_image_height - R) / verticalStride + 1;
+ if(ret <= 0 || ret > Integer.MAX_VALUE) {
+ // Check for valid output activation height
+ if(padded_image_height < R)
+ throw new RuntimeException("Incorrect parameters: padded image height:" + padded_image_height + " cannot be less than filter_height:" + R);
+ else
+ throw new RuntimeException("Incorrect parameters: height=" + H + " filter_height=" + R + " stride=" + verticalStride + " pad=" + heightPadding + " as P=" + ret);
+ }
+ return ret;
}
public static long getQ(long W, long S, long horizontalStride, long widthPadding) {
if(W <= 0 || S <= 0 || widthPadding < 0 || horizontalStride < 0) {
throw new RuntimeException("Incorrect parameters: width=" + W + " filter_width=" + S + " stride=" + horizontalStride + " pad=" + widthPadding);
}
- return (W + 2 * widthPadding - S) / horizontalStride + 1;
+ long padded_image_width = W + 2 * widthPadding;
+ long ret = (padded_image_width - S) / horizontalStride + 1;
+ if(ret <= 0 || ret > Integer.MAX_VALUE) {
+ // Check for valid output activation width
+ if(padded_image_width < S)
+ throw new RuntimeException("Incorrect parameters: padded image width:" + padded_image_width + " cannot be less than filter width:" + S);
+ else
+ throw new RuntimeException("Incorrect parameters: width=" + W + " filter_width=" + S + " stride=" + horizontalStride + " pad=" + widthPadding + " as Q=" + ret);
+ }
+ return ret;
}