@@ -188,10 +188,31 @@ void MKLDNNReLULayer<Dtype>::InitReLUBwd(const vector<Blob<Dtype>*>& top
188
188
if (top_diff_is_prv) {
189
189
shared_ptr<MKLDNNMemoryDescriptor<Dtype, /* is_diff */ true > > mem_descr
190
190
= get_mkldnn_prv_descriptor<Dtype, /* is_diff */ true >(top[0 ]);
191
+ #ifdef DEBUG
192
+ memory::format bwd_prv_top_diff_mfmt = static_cast <memory::format>(mem_descr->prv_memory_pd ()->desc ().data .format );
193
+ LOG (INFO) << " MKLDNNReLULayer<Dtype>::InitReLUBwd: memory format of prv top diff is: " << bwd_prv_top_diff_mfmt;
194
+ #endif
191
195
top_diff_md.reset (new memory::desc (mem_descr->prv_memory_pd ()->desc ()));
192
196
usr_diff_mpd = mem_descr->usr_memory_pd ();
193
197
prv_diff_mpd = mem_descr->prv_memory_pd ();
194
198
} else {
199
+ bool bottom_data_is_prv = (const_cast <Dtype*>(bottom[0 ]->prv_data ()) != NULL );
200
+ if (bottom_data_is_prv) {
201
+ shared_ptr<MKLDNNMemoryDescriptor<Dtype, false > > mem_descr
202
+ = get_mkldnn_prv_descriptor<Dtype, false >(bottom[0 ]);
203
+ #ifdef DEBUG
204
+ memory::format fwd_prv_bottom_data_mfmt = static_cast <memory::format>(mem_descr->prv_memory_pd ()->desc ().data .format );
205
+ LOG (INFO) << " MKLDNNReLULayer<Dtype>::InitReLUBwd: memory format of prv bottom data is: " << fwd_prv_bottom_data_mfmt;
206
+ LOG (INFO) << " MKLDNNReLULayer<Dtype>::InitReLUBwd: Reorder the usr top diff to the format of prv bottom data! (Performance consideration)" ;
207
+ #endif
208
+ prv_diff_mpd = mem_descr->prv_memory_pd ();
209
+ // top[0]->prv_data() is empty, however top[0]->get_prv_diff_descriptor() has value.
210
+ // Find root cause in the mkldnn_memory: create_output_memory() and sync_before_write() functions.
211
+ // But that a major fix, will lead the nan in the AlexNet training.
212
+ // So need investigation further, however, this will fix ICL-84.
213
+ top[0 ]->set_prv_diff_descriptor (NULL );
214
+ }
215
+
195
216
top_diff_md.reset (new memory::desc ({{n, ic, ih, iw}}, mpcsn, memory::format::nchw));
196
217
usr_diff_mpd.reset (new memory::primitive_desc (*top_diff_md, cpu_engine));
197
218
}
0 commit comments