@@ -10,12 +10,21 @@ void CuDNNSigmoidLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
1010 const vector<Blob<Dtype>*>& top) {
1111 const Dtype* bottom_data = bottom[0 ]->gpu_data ();
1212 Dtype* top_data = top[0 ]->mutable_gpu_data ();
13+ #if CUDNN_VERSION_MIN(5, 0, 0)
1314 CUDNN_CHECK (cudnnActivationForward (this ->handle_ ,
14- CUDNN_ACTIVATION_SIGMOID ,
15+ activ_desc_ ,
1516 cudnn::dataType<Dtype>::one,
1617 this ->bottom_desc_ , bottom_data,
1718 cudnn::dataType<Dtype>::zero,
1819 this ->top_desc_ , top_data));
20+ #else
21+ CUDNN_CHECK (cudnnActivationForward_v4 (this ->handle_ ,
22+ activ_desc_,
23+ cudnn::dataType<Dtype>::one,
24+ this ->bottom_desc_ , bottom_data,
25+ cudnn::dataType<Dtype>::zero,
26+ this ->top_desc_ , top_data));
27+ #endif
1928}
2029
2130template <typename Dtype>
@@ -30,13 +39,23 @@ void CuDNNSigmoidLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
3039 const Dtype* top_diff = top[0 ]->gpu_diff ();
3140 const Dtype* bottom_data = bottom[0 ]->gpu_data ();
3241 Dtype* bottom_diff = bottom[0 ]->mutable_gpu_diff ();
42+ #if CUDNN_VERSION_MIN(5, 0, 0)
3343 CUDNN_CHECK (cudnnActivationBackward (this ->handle_ ,
34- CUDNN_ACTIVATION_SIGMOID ,
44+ activ_desc_ ,
3545 cudnn::dataType<Dtype>::one,
3646 this ->top_desc_ , top_data, this ->top_desc_ , top_diff,
3747 this ->bottom_desc_ , bottom_data,
3848 cudnn::dataType<Dtype>::zero,
3949 this ->bottom_desc_ , bottom_diff));
50+ #else
51+ CUDNN_CHECK (cudnnActivationBackward_v4 (this ->handle_ ,
52+ activ_desc_,
53+ cudnn::dataType<Dtype>::one,
54+ this ->top_desc_ , top_data, this ->top_desc_ , top_diff,
55+ this ->bottom_desc_ , bottom_data,
56+ cudnn::dataType<Dtype>::zero,
57+ this ->bottom_desc_ , bottom_diff));
58+ #endif
4059}
4160
4261INSTANTIATE_LAYER_GPU_FUNCS (CuDNNSigmoidLayer);
0 commit comments