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

Commit

Permalink
Fix a bug in mkldnn copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
zheng-da committed May 7, 2018
1 parent 400c1b2 commit 9ff7f0b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/operator/nn/mkldnn/mkldnn_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ void MKLDNNCopy(const nnvm::NodeAttrs& attrs, const OpContext &ctx,
const NDArray &in_data, const OpReqType &req,
const NDArray &out_data) {
TmpMemMgr::Get()->Init(ctx.requested[0]);
auto in_mem = in_data.GetMKLDNNData();

// If the input data is a view of an MKLDNN array, we should create a new
// NDArray with reordered data.
NDArray data = in_data;
if (data.IsMKLDNNData() && data.IsView())
data = data.Reorder2Default();
auto in_mem = data.GetMKLDNNData();
if (req == kAddTo) {
TmpMemMgr::Get()->Init(ctx.requested[0]);
// We should try and force the output memory has the same format
Expand Down

0 comments on commit 9ff7f0b

Please sign in to comment.