From 0a326e7afe3e690c0b4cb64bbd0ce4f0603a7d85 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Tue, 07 Aug 2018 23:45:47 +0000
Subject: [PATCH] XNOR-net on CPU AVX2
---
src/network.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/network.c b/src/network.c
index 3df837d..63b76a8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -222,7 +222,7 @@
{
#ifdef GPU
if (gpu_index >= 0) return get_network_output_gpu(net);
-#endif
+#endif
int i;
for(i = net.n-1; i > 0; --i) if(net.layers[i].type != COST) break;
return net.layers[i].output;
@@ -366,7 +366,7 @@
/*
layer *l = net->layers + i;
cudnn_convolutional_setup(l, cudnn_fastest);
- // check for excessive memory consumption
+ // check for excessive memory consumption
size_t free_byte;
size_t total_byte;
check_error(cudaMemGetInfo(&free_byte, &total_byte));
@@ -520,7 +520,7 @@
if(l.type == CONVOLUTIONAL){
prev = visualize_convolutional_layer(l, buff, prev);
}
- }
+ }
}
void top_predictions(network net, int k, int *index)
@@ -684,7 +684,7 @@
}
}
free(X);
- return pred;
+ return pred;
}
matrix network_predict_data(network net, data test)
@@ -707,7 +707,7 @@
}
}
free(X);
- return pred;
+ return pred;
}
void print_network(network net)
@@ -749,7 +749,7 @@
printf("%5d %5d\n%5d %5d\n", a, b, c, d);
float num = pow((abs(b - c) - 1.), 2.);
float den = b + c;
- printf("%f\n", num/den);
+ printf("%f\n", num/den);
}
float network_accuracy(network net, data d)
@@ -847,3 +847,25 @@
}
}
}
+
+
+
+void calculate_binary_weights(network net)
+{
+ int j;
+ for (j = 0; j < net.n; ++j) {
+ layer *l = &net.layers[j];
+
+ if (l->type == CONVOLUTIONAL) {
+ //printf(" Merges Convolutional-%d and batch_norm \n", j);
+
+ if (l->xnor) {
+ //printf("\n %d \n", j);
+ size_t ldb_align = 256; // 256bit for AVX2
+ binary_transpose_align_weights(l, ldb_align);
+ }
+ }
+ }
+ //printf("\n calculate_binary_weights Done! \n");
+
+}
\ No newline at end of file
--
Gitblit v1.10.0