Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[mkldnn-v1.0] Must reorder and emplace weights for rnn inference primitives #16682

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/operator/nn/mkldnn/mkldnn_rnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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;
}

Expand Down