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

Commit

Permalink
Fix a mem error. (#10812)
Browse files Browse the repository at this point in the history
  • Loading branch information
zheng-da authored and piiswrong committed May 4, 2018
1 parent aabaab4 commit e49fdae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions include/mxnet/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,7 @@ class NDArray {
*/
NDArray Reorder2Default() const;

void InvalidateMKLDNNData() {
// Removing mkl_mem_ means the NDArray will store data in the default format.
ptr_->mkl_mem_ = nullptr;
}
void InvalidateMKLDNNData();

/*
* This function is used inside operators to reshape an array.
Expand Down
6 changes: 6 additions & 0 deletions src/ndarray/ndarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ const mkldnn::memory *NDArray::GetMKLDNNData() const {
}
}

void NDArray::InvalidateMKLDNNData() {
// Removing mkl_mem_ means the NDArray will store data in the default format.
if (ptr_->mkl_mem_ && ptr_->mkl_mem_->IsMKLDNN())
ptr_->mkl_mem_ = nullptr;
}

void NDArray::CopyFrom(const mkldnn::memory &mem) {
CHECK(ptr_ != nullptr) << "The NDArray hasn't been initialized";
if (ptr_->mkl_mem_ && ptr_->mkl_mem_->GetRaw() == &mem)
Expand Down

0 comments on commit e49fdae

Please sign in to comment.