Repository: incubator-systemml
Updated Branches:
  refs/heads/master efa8c4984 -> 02ff20045


[SYSTEMML-618] SystemML-NN: Updating `im2col` to use row-major left-indexing 
inside the loop, which is more performant with the latest changes in 
SYSTEMML-633.


Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/02ff2004
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/02ff2004
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/02ff2004

Branch: refs/heads/master
Commit: 02ff200452088a05049539bd23672da6102d94da
Parents: efa8c49
Author: Mike Dusenberry <[email protected]>
Authored: Wed Jun 22 17:15:44 2016 -0700
Committer: Mike Dusenberry <[email protected]>
Committed: Wed Jun 22 17:16:53 2016 -0700

----------------------------------------------------------------------
 scripts/staging/SystemML-NN/nn/util.dml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/02ff2004/scripts/staging/SystemML-NN/nn/util.dml
----------------------------------------------------------------------
diff --git a/scripts/staging/SystemML-NN/nn/util.dml 
b/scripts/staging/SystemML-NN/nn/util.dml
index 3f4d97b..8a97e81 100644
--- a/scripts/staging/SystemML-NN/nn/util.dml
+++ b/scripts/staging/SystemML-NN/nn/util.dml
@@ -136,7 +136,9 @@ im2col = function(matrix[double] img, int Hin, int Win, int 
Hf, int Wf, int stri
   Hout = as.integer((Hin - Hf) / strideh + 1)
   Wout = as.integer((Win - Wf) / stridew + 1)
 
-  img_cols = matrix(0, rows=C*Hf*Wf, cols=Hout*Wout)  # zeros
+  # Note: We start with `img_cols` transposed to allow for row-major
+  # left-indexing inside the loop, which is more performant.
+  img_cols = matrix(0, rows=Hout*Wout, cols=C*Hf*Wf)  # zeros
   parfor (hout in 1:Hout, check=0) {  # all output rows
     hin = (hout-1) * strideh + 1
     parfor (wout in 1:Wout, check=0) {  # all output columns
@@ -147,9 +149,10 @@ im2col = function(matrix[double] img, int Hin, int Win, 
int Hf, int Wf, int stri
         img_slice = matrix(img[c,], rows=Hin, cols=Win)  # reshape
         img_patch[c,] = matrix(img_slice[hin:hin+Hf-1, win:win+Wf-1], rows=1, 
cols=Hf*Wf)
       }
-      img_cols[,(hout-1)*Wout + wout] = matrix(img_patch, rows=C*Hf*Wf, 
cols=1)  # reshape
+      img_cols[(hout-1)*Wout + wout,] = t(matrix(img_patch, rows=C*Hf*Wf, 
cols=1))  # reshape
     }
   }
+  img_cols = t(img_cols)
 }
 
 col2im = function(matrix[double] img_cols, int C, int Hin, int Win, int Hf, 
int Wf,

Reply via email to