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

Fix a mem error. #10812

Merged
merged 1 commit into from
May 4, 2018
Merged
Show file tree
Hide file tree
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
Fix a mem error.
  • Loading branch information
zheng-da committed May 4, 2018
commit 75b796a8c1f02aec44e02fd9714049adbf30b86e
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