From 4a7862f4a676218bf545d1198b7b18a45d0a91af Mon Sep 17 00:00:00 2001 From: zixuanweeei Date: Thu, 31 Oct 2019 16:45:52 +0800 Subject: [PATCH] [mkldnn-v1.0] Must reorder and emplace weights for inference primitives --- src/operator/nn/mkldnn/mkldnn_rnn.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/operator/nn/mkldnn/mkldnn_rnn.cc b/src/operator/nn/mkldnn/mkldnn_rnn.cc index 0a788691da3a..e797b649d295 100644 --- a/src/operator/nn/mkldnn/mkldnn_rnn.cc +++ b/src/operator/nn/mkldnn/mkldnn_rnn.cc @@ -533,8 +533,7 @@ void MKLDNNRnnForward::SetWeightsMem(MKLDNNRnnMemMgr* mgr, void *w_ptr, void *b_ // their gradients. Then, forward training primitives could fetch them from the scope // of forward inference. And from there, we don't need to reorder the plain memory to // the optimal rnn-packed memory for forward inference. - if (!is_train) - ReorderWeights(); + ReorderWeights(); // Process bias MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { @@ -550,11 +549,10 @@ void MKLDNNRnnForward::SetWeightsMem(MKLDNNRnnMemMgr* mgr, void *w_ptr, void *b_ }); // insert weights into net_args - if (!is_train) { - EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_WEIGHTS_LAYER, this->weights_layer_); - EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_WEIGHTS_ITER, this->weights_iter_); - EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_BIAS, this->bias_); - } + EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_WEIGHTS_LAYER, this->weights_layer_); + EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_WEIGHTS_ITER, this->weights_iter_); + EmplaceNetArgs(&this->net_args_, MKLDNN_ARG_BIAS, this->bias_); + initialized_ = true; }