@@ -116,7 +116,7 @@ void CuDNNConvolutionLayer<Dtype>::Reshape(
116
116
cudnnConvolutionFwdAlgoPerf_t fwd_algo_pref_[4 ];
117
117
cudnnConvolutionBwdDataAlgoPerf_t bwd_data_algo_pref_[4 ];
118
118
119
- // get memory sizes
119
+ // get memory sizes
120
120
cudaMemGetInfo (&free_memory, &total_memory);
121
121
#else
122
122
// Specify workspace limit for kernels directly until we have a
@@ -142,46 +142,63 @@ void CuDNNConvolutionLayer<Dtype>::Reshape(
142
142
// Note: Copied from https://github.com/Qengineering/caffe/tree/ssd/src/caffe/layers
143
143
#if CUDNN_VERSION_MIN(8, 0, 0)
144
144
// choose forward algorithm for filter
145
- // in forward filter the CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED is not implemented in cuDNN 8
146
- CUDNN_CHECK (cudnnGetConvolutionForwardAlgorithm_v7 (handle_[0 ], bottom_descs_[i], filter_desc_, conv_descs_[i], top_descs_[i], 4 , &RetCnt, fwd_algo_pref_));
145
+ // in forward filter the CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED is not
146
+ // implemented in cuDNN 8
147
+ CUDNN_CHECK (cudnnGetConvolutionForwardAlgorithm_v7 (handle_[0 ],
148
+ bottom_descs_[i],
149
+ filter_desc_,
150
+ conv_descs_[i],
151
+ top_descs_[i],
152
+ 4 ,
153
+ &RetCnt,
154
+ fwd_algo_pref_));
147
155
148
156
found_conv_algorithm = false ;
149
- for (int n= 0 ;n< RetCnt;n++){
157
+ for (int n = 0 ; n < RetCnt; n++) {
150
158
if (fwd_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
151
- fwd_algo_pref_[n].algo != CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED &&
152
- fwd_algo_pref_[n].memory < free_memory){
159
+ fwd_algo_pref_[n].algo != CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED && // NOLINT(whitespace/line_length)
160
+ fwd_algo_pref_[n].memory < free_memory) {
153
161
found_conv_algorithm = true ;
154
162
fwd_algo_[i] = fwd_algo_pref_[n].algo ;
155
163
workspace_fwd_sizes_[i] = fwd_algo_pref_[n].memory ;
156
164
break ;
157
165
}
158
166
}
159
- if (!found_conv_algorithm) LOG (ERROR) << " cuDNN did not return a suitable algorithm for convolution." ;
160
- else {
167
+ if (!found_conv_algorithm) {
168
+ LOG (ERROR) << " cuDNN did not return a suitable algorithm for convolution." ; // NOLINT(whitespace/line_length)
169
+ } else {
161
170
// choose backward algorithm for filter
162
171
// for better or worse, just a fixed constant due to the missing
163
172
// cudnnGetConvolutionBackwardFilterAlgorithm in cuDNN version 8.0
164
173
bwd_filter_algo_[i] = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1;
165
- // twice the amount of the forward search to be save
174
+ // twice the amount of the forward search to be save
166
175
workspace_bwd_filter_sizes_[i] = 2 *workspace_fwd_sizes_[i];
167
176
}
168
177
169
178
// choose backward algo for data
170
- CUDNN_CHECK (cudnnGetConvolutionBackwardDataAlgorithm_v7 (handle_[0 ], filter_desc_, top_descs_[i], conv_descs_[i], bottom_descs_[i], 4 , &RetCnt, bwd_data_algo_pref_));
179
+ CUDNN_CHECK (cudnnGetConvolutionBackwardDataAlgorithm_v7 (handle_[0 ],
180
+ filter_desc_,
181
+ top_descs_[i],
182
+ conv_descs_[i],
183
+ bottom_descs_[i],
184
+ 4 ,
185
+ &RetCnt,
186
+ bwd_data_algo_pref_));
171
187
172
188
found_conv_algorithm = false ;
173
- for (int n= 0 ;n< RetCnt;n++){
189
+ for (int n = 0 ; n < RetCnt; n++) {
174
190
if (bwd_data_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
175
- bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD &&
176
- bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED &&
177
- bwd_data_algo_pref_[n].memory < free_memory){
191
+ bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD && // NOLINT(whitespace/line_length)
192
+ bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED && // NOLINT(whitespace/line_length)
193
+ bwd_data_algo_pref_[n].memory < free_memory) {
178
194
found_conv_algorithm = true ;
179
195
bwd_data_algo_[i] = bwd_data_algo_pref_[n].algo ;
180
196
workspace_bwd_data_sizes_[i] = bwd_data_algo_pref_[n].memory ;
181
197
break ;
182
198
}
183
199
}
184
- if (!found_conv_algorithm) LOG (ERROR) << " cuDNN did not return a suitable algorithm for convolution." ;
200
+ if (!found_conv_algorithm)
201
+ LOG (ERROR) << " cuDNN did not return a suitable algorithm for convolution." ; // NOLINT(whitespace/line_length)
185
202
#else
186
203
// choose forward and backward algorithms + workspace(s)
187
204
CUDNN_CHECK (cudnnGetConvolutionForwardAlgorithm (handle_[0 ],
0 commit comments