From 032e3b0cc00a15dd2af8b4fb82d261eb7b086e26 Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Mon, 12 Nov 2018 10:12:07 +0900 Subject: Add kernel_mode option to im2col, col2im, and convgemm functions --- src/routines/levelx/xcol2im.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/routines/levelx/xcol2im.cpp') diff --git a/src/routines/levelx/xcol2im.cpp b/src/routines/levelx/xcol2im.cpp index 7a0c36b7..d285e5c0 100644 --- a/src/routines/levelx/xcol2im.cpp +++ b/src/routines/levelx/xcol2im.cpp @@ -31,13 +31,17 @@ Xcol2im::Xcol2im(Queue &queue, EventPointer event, const std::string &name): // The main routine template -void Xcol2im::DoCol2im(const size_t channels, const size_t height, const size_t width, +void Xcol2im::DoCol2im(const KernelMode kernel_mode, + const size_t channels, const size_t height, const size_t width, const size_t kernel_h, const size_t kernel_w, const size_t pad_h, const size_t pad_w, const size_t stride_h, const size_t stride_w, const size_t dilation_h, const size_t dilation_w, const Buffer &col_buffer, const size_t col_offset, const Buffer &im_buffer, const size_t im_offset) { + // Flip the output along kernel_h and kernel_w, or not. + const auto kernel_name = (kernel_mode == KernelMode::kConvolution) ? "Xcol2imKernelFlip" : "Xcol2imKernelNormal"; + // Makes sure all dimensions are larger than zero if ((channels == 0) || (height == 0) || (width == 0)) { throw BLASError(StatusCode::kInvalidDimension); } @@ -59,7 +63,7 @@ void Xcol2im::DoCol2im(const size_t channels, const size_t height, const size EuclidGCD(static_cast(stride_w), static_cast(dilation_w), stride_bez_w, dilation_bez_w, gcd_w); // Retrieves the kernel from the compiled binary - auto kernel = Kernel(program_, "col2im"); + auto kernel = Kernel(program_, kernel_name); // Sets the kernel arguments kernel.SetArgument(0, static_cast(height)); -- cgit v1.2.3