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/05/08 03:34:49 UTC
incubator-systemml git commit: [SYSTEMML-1589] Check for the empty
block case
Repository: incubator-systemml
Updated Branches:
refs/heads/master 576eb4e96 -> 686363208
[SYSTEMML-1589] Check for the empty block case
Closes #487.
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/68636320
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/68636320
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/68636320
Branch: refs/heads/master
Commit: 6863632088c8d0b548a17413692b399d512a991d
Parents: 576eb4e
Author: Niketan Pansare <np...@us.ibm.com>
Authored: Sun May 7 19:34:12 2017 -0800
Committer: Niketan Pansare <np...@us.ibm.com>
Committed: Sun May 7 20:34:12 2017 -0700
----------------------------------------------------------------------
.../cp/ConvolutionCPInstruction.java | 22 ++++++++++----------
.../sysml/runtime/matrix/data/LibMatrixDNN.java | 2 +-
2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/68636320/src/main/java/org/apache/sysml/runtime/instructions/cp/ConvolutionCPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/ConvolutionCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/ConvolutionCPInstruction.java
index d428ed9..1331d64 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/cp/ConvolutionCPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/ConvolutionCPInstruction.java
@@ -226,7 +226,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
MatrixBlock outputBlock = new MatrixBlock(input.getNumRows(), input.getNumColumns(),
LibMatrixDNN.SUPPORTS_SPARSE_OUTPUTS && (input.isInSparseFormat() || dout.isInSparseFormat()));
- if( !input.isEmptyBlock() && !dout.isEmptyBlock() ) {
+ if( !input.isEmpty() && !dout.isEmpty() ) {
outputBlock.allocateDenseOrSparseBlock();
LibMatrixDNN.reluBackward(input, dout, outputBlock, _numThreads);
}
@@ -246,10 +246,10 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
throw new DMLRuntimeException("Expected the number of columns of bias matrix to be 1, but found " + bias.getNumColumns());
}
- if(input.isEmptyBlock() && bias.isEmptyBlock()) {
+ if(input.isEmpty() && bias.isEmpty()) {
outputBlock = new MatrixBlock(input.getNumRows(), input.getNumColumns(), true);
}
- else if(bias.isEmptyBlock()) {
+ else if(bias.isEmpty()) {
outputBlock = new MatrixBlock(input);
}
else {
@@ -274,7 +274,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
throw new DMLRuntimeException("Expected the number of columns of bias matrix to be 1, but found " + bias.getNumColumns());
}
- if(bias.isEmptyBlock()) {
+ if(bias.isEmpty()) {
// Anything multiplied by zero is zero
outputBlock = new MatrixBlock(input.getNumRows(), input.getNumColumns(), true);
}
@@ -342,7 +342,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
ConvolutionParameters params = new ConvolutionParameters(N, C, H, W, K, R, S, stride_h, stride_w, pad_h, pad_w, _numThreads);
params.enableNative = NativeHelper.isNativeLibraryLoaded();
if (instOpcode.equalsIgnoreCase("maxpooling") || instOpcode.equalsIgnoreCase("relu_maxpooling")) {
- if(matBlock.isEmptyBlock()) {
+ if(matBlock.isEmpty()) {
outputBlock = new MatrixBlock(N, C*P*Q, true);
}
else {
@@ -354,7 +354,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
}
else if (instOpcode.equalsIgnoreCase("maxpooling_backward") || instOpcode.equalsIgnoreCase("relu_maxpooling_backward")) {
MatrixBlock dout = ec.getMatrixInput(_in2.getName());
- if(matBlock.isEmptyBlock() || dout.isEmptyBlock()) {
+ if(matBlock.isEmpty() || dout.isEmpty()) {
outputBlock = new MatrixBlock(N, C*H*W, true);
}
else {
@@ -368,7 +368,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
}
else if (instOpcode.equalsIgnoreCase("conv2d")) {
MatrixBlock filter = ec.getMatrixInput(_in2.getName());
- if(filter.isEmptyBlock() || matBlock.isEmptyBlock()) {
+ if(filter.isEmpty() || matBlock.isEmpty()) {
outputBlock = new MatrixBlock(N, K*P*Q, true);
}
else {
@@ -383,12 +383,12 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
else if (instOpcode.equalsIgnoreCase("conv2d_bias_add")) {
MatrixBlock filter = ec.getMatrixInput(_in3.getName());
MatrixBlock bias = ec.getMatrixInput(_in2.getName());
- if((filter.isEmptyBlock() || matBlock.isEmptyBlock()) && bias.isEmptyBlock()) {
+ if((filter.isEmpty() || matBlock.isEmpty()) && bias.isEmpty()) {
outputBlock = new MatrixBlock(N, K*P*Q, true);
}
else {
outputBlock = getDenseOutputBlock(N, K*P*Q);
- if(!bias.isEmptyBlock()) {
+ if(!bias.isEmpty()) {
params.bias = bias;
}
if(params.enableNative && !isFilterSparse(filter) && !matBlock.isInSparseFormat())
@@ -401,7 +401,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
}
else if (instOpcode.equalsIgnoreCase("conv2d_backward_filter")) {
MatrixBlock dout = ec.getMatrixInput(_in2.getName());
- if(dout.isEmptyBlock() || matBlock.isEmptyBlock()) {
+ if(dout.isEmpty() || matBlock.isEmpty()) {
outputBlock = new MatrixBlock(K, C*R*S, true);
}
else {
@@ -415,7 +415,7 @@ public class ConvolutionCPInstruction extends UnaryCPInstruction
}
else if (instOpcode.equalsIgnoreCase("conv2d_backward_data")) {
MatrixBlock dout = ec.getMatrixInput(_in2.getName());
- if(dout.isEmptyBlock() || matBlock.isEmptyBlock()) {
+ if(dout.isEmpty() || matBlock.isEmpty()) {
outputBlock = new MatrixBlock(N, C * H * W, true);
}
else {
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/68636320/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixDNN.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixDNN.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixDNN.java
index 6a43917..e4d3ba2 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixDNN.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixDNN.java
@@ -1138,7 +1138,7 @@ public class LibMatrixDNN {
else {
// In all other cases, perform im2col in Java + matmult (either native or java).
MatrixBlock im2ColOutBlock = _im2ColOutBlocks.remove();
- double [] temp = _params.input1.isInSparseFormat() ? new double[_params.input1.getNumColumns()] : null;
+ double [] temp = (_params.input1.isInSparseFormat() || _params.input1.denseBlock == null) ? new double[_params.input1.getNumColumns()] : null;
for(int n = _rl; n < _ru; n++)
doLoopedIm2ColConv2d(n, im2ColOutBlock, _params, temp);
_im2ColOutBlocks.add(im2ColOutBlock);