Skip to content

Commit

Permalink
Revert "[MKLDNN]Fix reorder2default (apache#16602)" (apache#16697)
Browse files Browse the repository at this point in the history
This reverts commit dd4eaf5.
  • Loading branch information
ZhennanQin authored and anirudh2290 committed Nov 8, 2019
1 parent 954b63b commit e5b5366
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/ndarray/ndarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1623,13 +1623,11 @@ void NDArray::Save(dmlc::Stream *strm) const {
nd_cpu.WaitToRead();
save_data = nd_cpu.data();
} else {
#if MXNET_USE_MKLDNN == 1
// For mkldnn, a copy of *this can ensure no write access pending on *this.
nd_cpu = this->Copy(Context::CPU());
nd_cpu.WaitToRead();
#else
this->WaitToRead();
nd_cpu = *this;
#if MXNET_USE_MKLDNN == 1
if (nd_cpu.IsMKLDNNData())
nd_cpu = nd_cpu.Reorder2Default();
#endif
save_data = nd_cpu.data();
}
Expand Down Expand Up @@ -2024,18 +2022,15 @@ void NDArray::SyncCopyToCPU(void *data, size_t size) const {
TBlob dst(data, dshape, cpu::kDevMask, this->dtype_, 0); // NOLINT(*)

if (this->ctx().dev_mask() == cpu::kDevMask) {
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
RunContext ctx{this->ctx(), nullptr, nullptr, false};
NDArray src = *this;
this->WaitToRead();
RunContext rctx{this->ctx(), nullptr, nullptr, false};
NDArray src = *this;
#if MXNET_USE_MKLDNN == 1
src = this->Reorder2Default();
if (src.IsMKLDNNData())
src = this->Reorder2Default();
#endif
ndarray::Copy<cpu, cpu>(src.data(), &dst, Context::CPU(), Context::CPU(), ctx);
on_complete();
},
this->ctx(), {this->var()}, {}, FnProperty::kNormal, 0, "SyncCopyCPU2CPU");
this->WaitToWrite();
ndarray::Copy<cpu, cpu>(src.data(), &dst,
Context::CPU(), Context::CPU(), rctx);
} else {
#if MXNET_USE_CUDA
Engine::Get()->PushAsync(
Expand Down

0 comments on commit e5b5366

Please sign in to comment.