summaryrefslogtreecommitdiff
path: root/src/clblast_netlib_c.cpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2018-10-23 20:52:25 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2018-10-23 20:52:25 +0200
commitd45911b61dedafcbd74f65df263b4197697d6a81 (patch)
tree1f5d30db2f1b77a8258c5d0b331581938574d17e /src/clblast_netlib_c.cpp
parent44b630fc222c6e22446c20995411994b51bc2f21 (diff)
Added groundwork for col2im algorithm plus first non-working version of kernel and test
Diffstat (limited to 'src/clblast_netlib_c.cpp')
-rw-r--r--src/clblast_netlib_c.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/clblast_netlib_c.cpp b/src/clblast_netlib_c.cpp
index dbc2ba57..22570535 100644
--- a/src/clblast_netlib_c.cpp
+++ b/src/clblast_netlib_c.cpp
@@ -4967,4 +4967,94 @@ void cblas_zim2col(const int channels, const int height, const int width, const
col_buffer.Read(queue, col_size, reinterpret_cast<double2*>(col));
}
+// COL2IM
+void cblas_scol2im(const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w,
+ const float* col,
+ float* im) {
+ OPTIONAL_STATIC auto device = get_device();
+ OPTIONAL_STATIC auto context = clblast::Context(device);
+ auto queue = clblast::Queue(context, device);
+ const auto col_size = height * width * channels;
+ const auto im_size = height * width * channels;
+ auto col_buffer = clblast::Buffer<float>(context, col_size);
+ auto im_buffer = clblast::Buffer<float>(context, im_size);
+ col_buffer.Write(queue, col_size, reinterpret_cast<const float*>(col));
+ im_buffer.Write(queue, im_size, reinterpret_cast<float*>(im));
+ auto queue_cl = queue();
+ auto s = clblast::Col2im<float>(channels, height, width, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
+ col_buffer(), 0,
+ im_buffer(), 0,
+ &queue_cl);
+ if (s != clblast::StatusCode::kSuccess) {
+ throw std::runtime_error("CLBlast returned with error code " + clblast::ToString(s));
+ }
+ im_buffer.Read(queue, im_size, reinterpret_cast<float*>(im));
+}
+void cblas_dcol2im(const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w,
+ const double* col,
+ double* im) {
+ OPTIONAL_STATIC auto device = get_device();
+ OPTIONAL_STATIC auto context = clblast::Context(device);
+ auto queue = clblast::Queue(context, device);
+ const auto col_size = height * width * channels;
+ const auto im_size = height * width * channels;
+ auto col_buffer = clblast::Buffer<double>(context, col_size);
+ auto im_buffer = clblast::Buffer<double>(context, im_size);
+ col_buffer.Write(queue, col_size, reinterpret_cast<const double*>(col));
+ im_buffer.Write(queue, im_size, reinterpret_cast<double*>(im));
+ auto queue_cl = queue();
+ auto s = clblast::Col2im<double>(channels, height, width, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
+ col_buffer(), 0,
+ im_buffer(), 0,
+ &queue_cl);
+ if (s != clblast::StatusCode::kSuccess) {
+ throw std::runtime_error("CLBlast returned with error code " + clblast::ToString(s));
+ }
+ im_buffer.Read(queue, im_size, reinterpret_cast<double*>(im));
+}
+void cblas_ccol2im(const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w,
+ const void* col,
+ void* im) {
+ OPTIONAL_STATIC auto device = get_device();
+ OPTIONAL_STATIC auto context = clblast::Context(device);
+ auto queue = clblast::Queue(context, device);
+ const auto col_size = height * width * channels;
+ const auto im_size = height * width * channels;
+ auto col_buffer = clblast::Buffer<float2>(context, col_size);
+ auto im_buffer = clblast::Buffer<float2>(context, im_size);
+ col_buffer.Write(queue, col_size, reinterpret_cast<const float2*>(col));
+ im_buffer.Write(queue, im_size, reinterpret_cast<float2*>(im));
+ auto queue_cl = queue();
+ auto s = clblast::Col2im<float2>(channels, height, width, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
+ col_buffer(), 0,
+ im_buffer(), 0,
+ &queue_cl);
+ if (s != clblast::StatusCode::kSuccess) {
+ throw std::runtime_error("CLBlast returned with error code " + clblast::ToString(s));
+ }
+ im_buffer.Read(queue, im_size, reinterpret_cast<float2*>(im));
+}
+void cblas_zcol2im(const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w,
+ const void* col,
+ void* im) {
+ OPTIONAL_STATIC auto device = get_device();
+ OPTIONAL_STATIC auto context = clblast::Context(device);
+ auto queue = clblast::Queue(context, device);
+ const auto col_size = height * width * channels;
+ const auto im_size = height * width * channels;
+ auto col_buffer = clblast::Buffer<double2>(context, col_size);
+ auto im_buffer = clblast::Buffer<double2>(context, im_size);
+ col_buffer.Write(queue, col_size, reinterpret_cast<const double2*>(col));
+ im_buffer.Write(queue, im_size, reinterpret_cast<double2*>(im));
+ auto queue_cl = queue();
+ auto s = clblast::Col2im<double2>(channels, height, width, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
+ col_buffer(), 0,
+ im_buffer(), 0,
+ &queue_cl);
+ if (s != clblast::StatusCode::kSuccess) {
+ throw std::runtime_error("CLBlast returned with error code " + clblast::ToString(s));
+ }
+ im_buffer.Read(queue, im_size, reinterpret_cast<double2*>(im));
+}
+
// =================================================================================================