From 787d5345609459f21fd65d2d8b4fcd55201e21a1 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Mon, 13 Oct 2014 07:31:10 +0000
Subject: [PATCH] Convolutional working on GPU

---
 src/col2im.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/col2im.c b/src/col2im.c
index c418fa5..65db22a 100644
--- a/src/col2im.c
+++ b/src/col2im.c
@@ -80,11 +80,32 @@
     cl.error = clSetKernelArg(kernel, i++, sizeof(data_im), (void*) &data_im);
     check_error(cl);
 
-    size_t global_size = {channels*height*width*batch};
+    size_t global_size = channels*height*width*batch;
 
-    clEnqueueNDRangeKernel(queue, kernel, 3, 0,
-            global_size, 0, 0, 0, 0);
+    clEnqueueNDRangeKernel(queue, kernel, 1, 0,
+            &global_size, 0, 0, 0, 0);
     check_error(cl);
 }
 
+void col2im_gpu(float *data_col,  int batch,
+         int channels,  int height,  int width,
+         int ksize,  int stride,  int pad, float *data_im) 
+{
+    int height_col = (height - ksize) / stride + 1;
+    int width_col = (width - ksize) / stride + 1;
+    int channels_col = channels * ksize * ksize;
+
+    size_t size = height_col*width_col*channels_col*batch;
+    cl_mem col_gpu = cl_make_array(data_col, size);
+    size = channels*height*width*batch;
+    cl_mem im_gpu = cl_make_array(data_im, size);
+
+    col2im_ongpu(col_gpu, batch, channels, height, width,
+            ksize, stride, pad, im_gpu);
+
+    cl_read_array(im_gpu, data_im, size);
+    clReleaseMemObject(col_gpu);
+    clReleaseMemObject(im_gpu);
+}
+
 #endif

--
Gitblit v1.10.0