From 5ce519c44c34e4c14193220d7aea5fdf760c5231 Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Wed, 10 Sep 2014 21:51:58 -0700 Subject: [PATCH] separate setTensor4dDesc from createTensor4dDesc This will make it possible to add reshaping to cuDNN layers. --- include/caffe/util/cudnn.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/caffe/util/cudnn.hpp b/include/caffe/util/cudnn.hpp index e7ddea7..aef3e21 100644 --- a/include/caffe/util/cudnn.hpp +++ b/include/caffe/util/cudnn.hpp @@ -56,22 +56,26 @@ template<> class dataType { }; template -inline void createTensor4dDesc(cudnnTensor4dDescriptor_t* desc, +inline void createTensor4dDesc(cudnnTensor4dDescriptor_t* desc) { + CUDNN_CHECK(cudnnCreateTensor4dDescriptor(desc)); +} + +template +inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc, int n, int c, int h, int w, int stride_n, int stride_c, int stride_h, int stride_w) { - CUDNN_CHECK(cudnnCreateTensor4dDescriptor(desc)); CUDNN_CHECK(cudnnSetTensor4dDescriptorEx(*desc, dataType::type, n, c, h, w, stride_n, stride_c, stride_h, stride_w)); } template -inline void createTensor4dDesc(cudnnTensor4dDescriptor_t* desc, +inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc, int n, int c, int h, int w) { const int stride_w = 1; const int stride_h = w * stride_w; const int stride_c = h * stride_h; const int stride_n = c * stride_c; - createTensor4dDesc(desc, n, c, h, w, + setTensor4dDesc(desc, n, c, h, w, stride_n, stride_c, stride_h, stride_w); } -- 2.7.4