From dbdd31ee211fe8b1ac7e93ceadf7b34b8d304f34 Mon Sep 17 00:00:00 2001
From: Roland Singer <roland.singer@desertbit.com>
Date: Wed, 22 Aug 2018 11:56:41 +0000
Subject: [PATCH] updated README to include information about learning rate adjustment for multiple GPUs

---
 src/convolutional_layer.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/convolutional_layer.c b/src/convolutional_layer.c
index 7dc7dd2..e7c8e3f 100644
--- a/src/convolutional_layer.c
+++ b/src/convolutional_layer.c
@@ -44,7 +44,7 @@
         }
         mean = mean / size;
         for(i = 0; i < size; ++i){
-            binary[f*size + i] = (weights[f*size + i] > 0) ? mean : -mean;
+            binary[f*size + i] = (weights[f*size + i] > 0) ? mean: -mean;
         }
     }
 }
@@ -621,7 +621,7 @@
     free(align_weights);
 }
 
-
+// further optimizations: im2col_bin() for XNOR, and then transpose_aling_bin()
 size_t binary_transpose_align_input(int k, int n, float *b, char **t_bit_input, size_t ldb_align)
 {
     size_t new_ldb = k + (ldb_align - k%ldb_align); // (k / 8 + 1) * 8;
@@ -688,8 +688,10 @@
         //    t_input = calloc(t_intput_size, sizeof(float));
         //    im2col_cpu_custom_transpose(state.input, l.c, l.h, l.w, l.size, l.stride, l.pad, t_input, new_ldb);
         //}
+        //if (l.xnor && l.size == 3 && l.stride == 1 && l.pad == 1) {}
         //else
-            im2col_cpu_custom(state.input, l.c, l.h, l.w, l.size, l.stride, l.pad, b);
+        // further optimizations: im2col_bin() for XNOR, and then transpose_aling_bin()
+        im2col_cpu_custom(state.input, l.c, l.h, l.w, l.size, l.stride, l.pad, b);
 
 
         //gemm(0,0,m,n,k,1,a,k,b,n,1,c,n);
@@ -772,18 +774,28 @@
                 */
 
                 /*
-                if (l.size == 3 && l.stride == 1 && l.pad == 1) {
+                if (l.size == 3 && l.stride == 1 && l.pad == 1)
+                {
+                    //binarize_weights(l.weights, l.n, l.c*l.size*l.size, l.binary_weights);
+                    //printf("\n mean = %f \n", l.mean_arr[0]);
+
                     convolution_2d(l.w, l.h, l.size, l.n, l.c, l.pad, l.stride,
-                        l.weights, state.input, l.output);
+                        //l.weights, state.input, l.output, l.mean_arr);
+                        l.binary_weights, state.input, l.output, l.mean_arr);
                 }
                 else {
-                */
+                    */
+
                     //size_t ldb_align = 256; // 256 bit for AVX2
                     int ldb_align = l.lda_align;
                     size_t new_ldb = k + (ldb_align - k%ldb_align);
                     char *t_bit_input = NULL;
                     size_t t_intput_size = binary_transpose_align_input(k, n, b, &t_bit_input, ldb_align);
+                    //char *t_bit_input = calloc(new_ldb * n, sizeof(char));    // for im2col_cpu_custom_transpose() only
+                    //float_to_bit(t_input, t_bit_input, new_ldb * n);    // for im2col_cpu_custom_transpose() only
 
+                    // 5x times faster than gemm()-float32
+                    // further optimizations: accelerate maxpool-layer with OpenMP/AVX
                     gemm_nn_custom_bin_mean_transposed(m, n, k, 1, l.align_bit_weights, new_ldb, t_bit_input, new_ldb, c, n, l.mean_arr);
 
                     //gemm_nn_custom_bin_mean_transposed(m, n, k, 1, bit_weights, k, t_bit_input, new_ldb, c, n, mean_arr);

--
Gitblit v1.10.0